//------------ // void InitLogoMemory( void ) { int i, count; int countTvSvc, countRadioSvc; TYPE_TapChInfo currentChInfo; TAP_Channel_GetTotalNum( &countTvSvc, &countRadioSvc ); // how many services are defined on this box? if ( countTvSvc > MAX_SERVICES/2 ) { // must quit if too many services // ErrorPrint("Too many services"); // TF5800 won't be affected - so hack ok for us // return; // temp - must fix. countTvSvc = MAX_SERVICES/2; } if ( countRadioSvc > MAX_SERVICES/2 ) { countRadioSvc = MAX_SERVICES/2; } for ( i=0; i<=countTvSvc; i++) // for each TV service { TAP_Channel_GetInfo( SVC_TYPE_Tv, i, ¤tChInfo ); // get the info pointer strcpy( logoArrayTv[i].svcName, currentChInfo.chName); // and copy the channel's name logoArrayTv[i].svcLCN = currentChInfo.logicalChNum; // service LCN logoArrayTv[i].svcNum = i; // service number logoArrayTv[i].svcType = SVC_TYPE_Tv; // service type (TV, or Radio) logoArrayTv[i].processedFlag = FALSE; // no logo cached yet logoArrayTv[i].logo = TAP_MemAlloc( LOGO_DATA_SIZE ); // allocate space for the logo CreateFileName( &logoArrayTv[i] ); // filter out puntuation and generate a file name } for ( i=0; i<=countRadioSvc; i++) // do the same for each radio service on this box { TAP_Channel_GetInfo( SVC_TYPE_Radio, i, ¤tChInfo ); strcpy( logoArrayRadio[i].svcName, currentChInfo.chName); logoArrayRadio[i].svcLCN = currentChInfo.logicalChNum; // service LCN logoArrayRadio[i].svcNum = i; logoArrayRadio[i].svcType = SVC_TYPE_Radio; logoArrayRadio[i].processedFlag = FALSE; logoArrayRadio[i].logo = TAP_MemAlloc( LOGO_DATA_SIZE ); CreateFileName( &logoArrayRadio[i] ); // filter out puntuation and generate a file name } maxTvSvc = countTvSvc; // save the number of services for later maxRadioSvc = countRadioSvc; logoIndex = 0; }
void *FMUC_ReserveMemory(char *Requester, dword size) { tFMUC_MemDebug *Mem; void *ret; dword NrReservations, NrTotalSize; ret = TAP_MemAlloc(size); return ret; Mem = FMUC_MemoryFindFree(); if(Mem == NULL) { LogEntryFBLibPrintf(TRUE, "FMUC_ReserveMemory: no space in lookup table"); return ret; } Mem->Requester = Requester; Mem->Size = size; Mem->Alloc = ret; FMUC_MemoryDump(&NrReservations, &NrTotalSize); LogEntryFBLibPrintf(TRUE, "FMUC: %s has requested %d bytes. Currently %d, %d bytes", Requester, size, NrReservations, NrTotalSize); return ret; }
bool StringDBInit(tStringDB *StringDB, dword InitialSize) { TRACEENTER(); bool ret; if(!StringDB) { TRACEEXIT(); return FALSE; } StringDB->DBSize = InitialSize; if(InitialSize) { StringDB->DB = TAP_MemAlloc(InitialSize); if(StringDB->DB) TAP_MemSet(StringDB->DB, 0, InitialSize); } else StringDB->DB = NULL; StringDB->DBPtr = StringDB->DB; StringDB->DBEnd = StringDB->DB; ret = (StringDB->DB != NULL) || (InitialSize == 0); TRACEEXIT(); return ret; }
void DialogWindowInfoAddIcon (dword X, dword Y, TYPE_GrData *IconGd) { tDialogInfoItem *item, *last = NULL; if (!FBDialogWindow) return; item = FBDialogWindow->InfoItems; while (item) { last = item; item = item->next; } if ((item = TAP_MemAlloc(sizeof(tDialogInfoItem)))) { memset(item, 0, sizeof(tDialogInfoItem)); item->ItemType = InfoIcon; item->X = X; item->Y = Y; item->data = IconGd; item->next = NULL; if (last) last->next = item; else FBDialogWindow->InfoItems = item; FBDialogWindow->OSDInfoForeDirty = TRUE; } }
void SaveDatToFile( void ) { TYPE_File *writeFile; int i; char str[256]; appendToLogfile("SaveDatToFile: Started.", INFO); playDataBuffer_ini = TAP_MemAlloc( PLAYBACKDATA_BUFFER_SIZE_ini ); // Buffer the write data to memory before writing all in one hit memset( playDataBuffer_ini, '\0', PLAYBACKDATA_BUFFER_SIZE_ini ); // set the whole buffer to the string termination character (null) playDataBufferPtr_ini = 0; TAP_SPrint(str, "%d\r\n", numberOfPlayedFiles); // First entry is the number of played files. WriteStrToDatBuf( str ); for (i = 0; i <= numberOfPlayedFiles; i++) { // Write entry TAB with delimited fields. // 1. startcluster // 2. current block position. // 3. total block size. // 4. filename. TAP_SPrint(str, "%d\t%d\t%d\t%s\r\n", playedFiles[i]->startCluster, playedFiles[i]->currentBlock, playedFiles[i]->totalBlock, playedFiles[i]->name); WriteStrToDatBuf( str ); } appendToLogfile("SaveDatToFile: WriteDatFile called to write DATA file.", WARNING); WriteDatFile( writeFile ); // write all the data in one pass TAP_MemFree( playDataBuffer_ini ); // must return the memory back to the heap appendToLogfile("SaveDatToFile: Finished.", INFO); }
bool StringDBLoad(tStringDB *StringDB, char *FileName) { TRACEENTER(); int f; bool ret; dword l, p; char AbsFileName[FBLIB_DIR_SIZE]; if(!StringDB || !StringDB->DB || !FileName || !*FileName) { TRACEEXIT(); return FALSE; } ConvertPathType(FileName, AbsFileName, PF_FullLinuxPath); ret = FALSE; if(*AbsFileName) { f = open(AbsFileName, O_RDONLY); if(f >= 0) { TAP_MemFree(StringDB->DB); //DB Size read(f, &l, sizeof(dword)); StringDB->DB = TAP_MemAlloc(l); if(!StringDB->DB) { StringDB->DBSize = 0; close(f); TRACEEXIT(); return FALSE; } StringDB->DBSize = l; StringDB->DBEnd = l + StringDB->DB - 1; //Current pointer read(f, &p, sizeof(dword)); StringDB->DBPtr = p + StringDB->DB; read(f, StringDB->DB, l); close(f); ret = TRUE; } } TRACEEXIT(); return ret; }
void LoadPlayData( void ) { int i; char str[200]; appendToLogfile("LoadPlayData: Started.", INFO); if ( !ReadDatFile() ) // If we can't find/read the data file, create an empty one. { appendToLogfile("LoadPlayData: Call to ReadDatFile returned FALSE.", ERR); numberOfPlayedFiles = 1; playedFiles[0] = TAP_MemAlloc( sizeof (*playedFiles[0])); playedFiles[0]->startCluster = 0; // Store the disk start cluster. playedFiles[0]->currentBlock = 0; // Store the current block position. playedFiles[0]->totalBlock = 1; // Store the total block size. Set to 1 to ensure no division by 0 errors. strcpy(playedFiles[0]->name,"Placeholder for last played file.rec"); // Store the file name. playedFiles[1] = TAP_MemAlloc( sizeof (*playedFiles[1])); playedFiles[1]->startCluster = 12345678; // Store the disk start cluster. playedFiles[1]->currentBlock = 9876543; // Store the current block position. playedFiles[1]->totalBlock = 9999999; // Store the total block size. strcpy(playedFiles[1]->name,"This is a dummy filename.rec"); // Store the file name. appendToLogfile("LoadPlayData: Calling SaveDataToFile for new file.", ERR); SaveDatToFile(); } playbackInfoTick = TAP_GetTick(); // Set timer to indicate when we retrieved the playback information. playinfoChanged = FALSE; // We've just loaded the data, so it hasn't changed yet. /* TAP_Print("\r\n from loading numberOfPlayedFiles=%d \r\n",numberOfPlayedFiles); for (i = 1; i<=numberOfPlayedFiles; i ++) { TAP_Print("%d<< %d<< %d<<\r\n", playedFiles[i]->startCluster, playedFiles[i]->currentBlock, playedFiles[i]->totalBlock); TAP_Print("%s<<\r\n", playedFiles[i]->name); } */ appendToLogfile("LoadPlayData: Finished.", INFO); }
bool ReadConfigurationFile( void ) { TYPE_File *readFile = NULL; int i = 0; dword fileLength = 0; bool schSaveIniFile = FALSE; GotoPath( SETTINGS_FOLDER ); if ( ! TAP_Hdd_Exist( OPTIONS_FILENAME ) ) { GotoTapDir(); TAP_Hdd_ChangeDir( PROJECT_DIRECTORY ); if ( ! TAP_Hdd_Exist( OPTIONS_FILENAME ) ) return FALSE; schSaveIniFile = TRUE; } readFile = TAP_Hdd_Fopen( OPTIONS_FILENAME ); if ( readFile == NULL ) return FALSE; // and we can open it ok dataBuffer_ini = TAP_MemAlloc( DATA_BUFFER_SIZE_ini ); // Read the data in one hit (quicker), then process from RAM memset( dataBuffer_ini, '\0', DATA_BUFFER_SIZE_ini ); // set the whole buffer to the string termination character (null) dataBufferPtr_ini = 0; fileLength = TAP_Hdd_Flen( readFile ); // how big is the file if ( fileLength > DATA_BUFFER_SIZE_ini ) fileLength = DATA_BUFFER_SIZE_ini; // ensure we don't overflow the buffer TAP_Hdd_Fread( dataBuffer_ini, fileLength, 1, readFile ); // grab all the data from the file TAP_Hdd_Fclose( readFile ); if(SetConfigurationVariables() == FALSE) { TAP_MemFree( dataBuffer_ini ); // must return the memory back to the heap SaveConfigurationToFile(); } else { TAP_MemFree( dataBuffer_ini ); // must return the memory back to the heap } if(schSaveIniFile == TRUE) { SaveConfigurationToFile(); GotoTapDir(); TAP_Hdd_ChangeDir( PROJECT_DIRECTORY ); if ( TAP_Hdd_Exist( OPTIONS_FILENAME ) ) TAP_Hdd_Delete( OPTIONS_FILENAME ); } return TRUE; }
//--------------- // void KeyAdd( keyCodes_Struct *keyCodes, dword key, char *description ) { key_Struct *newItem; if ( keyCodes->count >= MAX_NUMBER_OF_KEYS ) return; // bounds check keyCodes->count++; newItem = TAP_MemAlloc( sizeof( key_Struct ) ); // allocate some memory to store the pointers to the strings newItem->keyCode = key; // note, the strings are not copied, they remain in the source code. newItem->ButtonText = description; keyCodes->keys[ keyCodes->count ] = newItem; // point to the newly allocated memory }
void MenuAdd( menu_Struct *menu, char *title, char *description ) { menuItem_Struct *newItem; if ( menu->count >= MAX_NUMBER_OF_MENU_ITEMS ) return; // bounds check menu->count++; newItem = TAP_MemAlloc( sizeof( menuItem_Struct ) ); // allocate some memory to store the pointers to the strings newItem->title = title; // note, the strings are not copied, they remain in the source code. newItem->description = description; menu->items[ menu->count ] = newItem; // point to the newly allocated memory }
void SaveConfigurationToFile( void ) { TYPE_File *writeFile = NULL; int i = 0; char str[256]; dataBuffer_ini = TAP_MemAlloc( DATA_BUFFER_SIZE_ini ); // Buffer the write data to memory before writing all in one hit memset( dataBuffer_ini, '\0', DATA_BUFFER_SIZE_ini ); // set the whole buffer to the string termination character (null) dataBufferPtr_ini = 0; switch ( unitModelType ) { case TF5800 : TAP_SPrint(str, "TF5800\r\n" ); break; case TF5000 : TAP_SPrint(str, "TF5000\r\n" ); break; default : TAP_SPrint(str, "BAD\r\n" ); break; } WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", mainActivationKey ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainPerformSearchMode ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainPerformSearchTime ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", FirmwareCallsEnabled ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainTRCEnabled ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainPerformSearchDays ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainDateFormat ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainTimeFormat ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", keyboardLanguage ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainConflictOption ); WriteStrToIniBuf( str ); WriteIniFile( writeFile ); // write all the data in one pass TAP_MemFree( dataBuffer_ini ); // must return the memory back to the heap }
TAPCOM_Channel TAPCOM_OpenChannel(dword TargetID, dword ServiceID, dword ParamBlockVersion, void *ParamBlock) { TRACEENTER(); TAPCOM_InternalMesBuf *mesBuf = NULL; if(!LibInitialized && !InitTAPex()) { TRACEEXIT(); return NULL; } mesBuf = (TAPCOM_InternalMesBuf *) TAP_MemAlloc(sizeof(TAPCOM_InternalMesBuf)); if(mesBuf) { // Speicherbereich für Nachrichtenaustausch anlegen mesBuf->tapcomSignature = TAPCOM_SIGNATURE; mesBuf->tapcomVersion = TAPCOM_VERSION; mesBuf->ServerAlive = 0; mesBuf->FromID = __tap_ud__; mesBuf->ToID = TargetID; mesBuf->ServiceID = ServiceID; mesBuf->ParamBlockVersion = ParamBlockVersion; mesBuf->ParamBlock = ParamBlock; mesBuf->Status = TAPCOM_Status_OPEN; mesBuf->ReturnVal = 0; mesBuf->Reserved = 0; //Existiert der Ziel-Server überhaupt? if((TargetID != TAPCOM_App_BROADCAST) && !HDD_TAP_isRunning(TargetID)) { mesBuf->Status = TAPCOM_Status_SERVER_NOT_AVAILABLE; } else { // TAPCOM Event mit der Adresse des Message-Buffers versenden. HDD_TAP_SendEvent(TargetID, FALSE, EVT_TAPCOM, (dword) mesBuf, 0); } } TRACEEXIT(); return (TAPCOM_Channel) mesBuf; }
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 SetDatVariables( void ) { int index; numberOfPlayedFiles = ReadDatDecimal(); // First entry is the number of played files. if (numberOfPlayedFiles > MAX_FILES) // Boundary check. numberOfPlayedFiles = MAX_FILES; for (index = 0; index<=numberOfPlayedFiles; index ++) { playedFiles[index] = TAP_MemAlloc( sizeof (*playedFiles[index])); playedFiles[index]->startCluster = ReadDatDecimal(); // Read the disk start cluster. playedFiles[index]->currentBlock = ReadDatDecimal(); // Read the current block position. playedFiles[index]->totalBlock = ReadDatDecimal(); // Read the total block size. strcpy(playedFiles[index]->name,ReadDatField()); // Read the file name. } }
bool StrMkUTF8(byte *SourceString, byte DefaultISO8859CharSet) { TRACEENTER(); char *_utf8string, *pEOS; int l; if(!SourceString) { TRACEEXIT(); return FALSE; } //To handle UTF32 strings correctly, SourceString need to be terminated by 4 NULL bytes pEOS = SourceString; while(pEOS[0] || pEOS[1] || pEOS[2] || pEOS[3]) pEOS++; l = ((dword)pEOS - (dword)SourceString) << 2; if(l == 0) { *SourceString = '\0'; TRACEEXIT(); return TRUE; } _utf8string = TAP_MemAlloc(l); if(!_utf8string) { TRACEEXIT(); return FALSE; } memset(_utf8string, 0, l); StrToUTF8(SourceString, _utf8string, DefaultISO8859CharSet); strcpy(SourceString, _utf8string); TAP_MemFree(_utf8string); TRACEEXIT(); return TRUE; }
bool StringDBLoadFromFile(tStringDB *StringDB, TYPE_File *f) { TRACEENTER(); dword l, p; if(!StringDB || !f) { TRACEEXIT(); return FALSE; } TAP_MemFree(StringDB->DB); //DB Size TAP_Hdd_Fread(&l, sizeof(dword), 1, f); StringDB->DB = TAP_MemAlloc(l); if(!StringDB->DB) { StringDB->DBSize = 0; TAP_Hdd_Fclose(f); TRACEEXIT(); return FALSE; } StringDB->DBSize = l; StringDB->DBEnd = l + StringDB->DB - 1; //Current pointer TAP_Hdd_Fread(&p, sizeof(dword), 1, f); StringDB->DBPtr = p + StringDB->DB; TAP_Hdd_Fread(StringDB->DB, 1, l, f); TRACEEXIT(); return TRUE; }
//------------ // void populateMoveFileList(void) { int index, numberOfEntries; appendToLogfile("populateMoveFileList: Started.", WARNING); numberOfEntries = myfolders[CurrentDirNumber]->numberOfFiles; numberOfDestinationFolders = 0; for ( index=1; index<=numberOfEntries ; index++) { switch (myfiles[CurrentDirNumber][index]->attr) { case PARENT_DIR_ATTR: case 240: // Parent Directory ".." case ATTR_FOLDER: // Normal Folder // Make sure we don't include the current folder that we may be trying to move. if (index == chosenLine) break; numberOfDestinationFolders++; if (moveFiles[numberOfDestinationFolders] == NULL) { moveFiles[numberOfDestinationFolders] = TAP_MemAlloc( sizeof (*moveFiles[numberOfDestinationFolders])); } memset(moveFiles[numberOfDestinationFolders],0,sizeof (*moveFiles[numberOfDestinationFolders])); if (myfiles[CurrentDirNumber][index]->attr == ATTR_FOLDER) // Normal folder so use the folder name. strcat(moveFiles[numberOfDestinationFolders]->name, myfiles[CurrentDirNumber][index]->name); else // Parent Directory, so use ".." strcat(moveFiles[numberOfDestinationFolders]->name, ".."); break; case ATTR_TS: default: break; } } appendToLogfile("populateMoveFileList: Finished.", WARNING); }
bool ReadDatFile( void ) { TYPE_File *readFile; int i; dword fileLength; appendToLogfile("ReadDatFile: Started.", INFO); GotoPath( TAPIniDir ); if ( ! TAP_Hdd_Exist( PLAYDATA_FILENAME ) ) { appendToLogfile("ReadDatFile: no PLAYDATA file found.", ERR); return FALSE; // check the ini file exits in the current directory } readFile = TAP_Hdd_Fopen( PLAYDATA_FILENAME ); if ( readFile == NULL ) return FALSE; // and we can open it ok playDataBuffer_ini = TAP_MemAlloc( PLAYBACKDATA_BUFFER_SIZE_ini ); // Read the data in one hit (quicker), then process from RAM memset( playDataBuffer_ini, '\0', PLAYBACKDATA_BUFFER_SIZE_ini ); // set the whole buffer to the string termination character (null) playDataBufferPtr_ini = 0; fileLength = TAP_Hdd_Flen( readFile ); // how big is the file if ( fileLength > PLAYBACKDATA_BUFFER_SIZE_ini ) fileLength = PLAYBACKDATA_BUFFER_SIZE_ini; // ensure we don't overflow the buffer TAP_Hdd_Fread( playDataBuffer_ini, fileLength, 1, readFile ); // grab all the data from the file TAP_Hdd_Fclose( readFile ); SetDatVariables(); TAP_MemFree( playDataBuffer_ini ); // must return the memory back to the heap appendToLogfile("ReadDatFile: Finished.", INFO); return TRUE; }
//------------ // void ReadLogoFile() { TYPE_File *logoFile; TYPE_logoArray *logoPointer; dword dataSize; byte *junkBuffer; char channelName[CHANNEL_NAME_SIZE]; int i; //+++ // TAP_Hdd_ChangeDir("UK TAP Project"); GotoPath( TAPIniDir ); if ( ! TAP_Hdd_Exist( "logo.dat" ) ) return; // check our logo file exits in the current directory logoFile = TAP_Hdd_Fopen( "logo.dat" ); if ( logoFile == NULL ) return; // and we can open it ok junkBuffer = TAP_MemAlloc(LOGO_DATA_SIZE); // create a place to read in unwanted logos while ( TAP_Hdd_Ftell( logoFile ) < TAP_Hdd_Flen( logoFile ) ) // Keep reading logos until we reach the end of file { TAP_Hdd_Fread( channelName, CHANNEL_NAME_SIZE, 1, logoFile ); // read the channel name if ( findChannelPointer( channelName, &logoPointer ) ) // cross referece the array to find this entry { // if the channel exists -> TAP_Hdd_Fread( logoPointer->logo, LOGO_DATA_SIZE, 1, logoFile ); // read the logo bitmap logoPointer->processedFlag = TRUE; // mark this channel as having a logo in the cache } else { // else channel doesn't appear in service list -> TAP_Hdd_Fread( junkBuffer, LOGO_DATA_SIZE, 1, logoFile ); // must read the logo, otherwise read pointer will get stuck } } TAP_Hdd_Fclose( logoFile ); // TAP_Hdd_ChangeDir(".."); // return to original directory TAP_MemFree( junkBuffer ); }
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(); }
void CheckPlaybackStatus( void ) { bool matchFound; int i, l, l1, l2; // Check for Playbackmode iOverRunCheck = ApiOverRunCheck; // Set flag to catch any buffer overrun from API call. TAP_Hdd_GetPlayInfo (&CurrentPlaybackInfo); if ( iOverRunCheck != ApiOverRunCheck ) // TAP_Hdd_GetPlayInfo V1.22 has a buffer overrun issue, so check if it has overrun by more than 128 bytes. { ShowMessageWin( rgn, "Archive: Error retrieving Playback Info", "TAP_Hdd_GetPlayInfo buffer overrun", "in 'CheckPlaybackStatus'.", 500 ); return; } // Check the various playmodes to see if we are playing a file back. // PLAYMODE_None Nothing playing // PLAYMODE_Playing Playing a file // PLAYMODE_RecPlaying Playing a currently recording file // // If we're not in playback then just return. if (CurrentPlaybackInfo.playMode != PLAYMODE_Playing) // We're not in playback mode { if (inPlaybackMode) // We were in playback mode, but now we've stopped. { SaveDatToFile(); // Write the information (particularly the last played file details) to disk } inPlaybackMode = FALSE; return; } inPlaybackMode = TRUE; // Assign variable to the file entry for easier use. CurrentPlaybackFile = CurrentPlaybackInfo.file; // Copy the current playing info to the 'last' variable so we can restart the very last playback. playedFiles[0]->startCluster = CurrentPlaybackFile->startCluster; // Save the disk start cluster. playedFiles[0]->currentBlock = CurrentPlaybackInfo.currentBlock; // Save the current block position. playedFiles[0]->totalBlock = CurrentPlaybackInfo.totalBlock; // Save the total block size. strcpy(playedFiles[0]->name,CurrentPlaybackFile->name); // Save the file name. matchFound = FALSE; // Search through the existing played file list to see if we have a match. for (i=1; i<=numberOfPlayedFiles; i++) { l1 = strlen(playedFiles[i]->name); l2 = strlen(CurrentPlaybackFile->name); l = max(l1, l2); if ((playedFiles[i]->startCluster == CurrentPlaybackFile->startCluster) && (strncmp(playedFiles[i]->name,CurrentPlaybackFile->name,TS_FILE_NAME_SIZE)==0)) { // If we match an existing entry in our playedFiles array, update the currentBlock position information. playedFiles[i]->currentBlock = CurrentPlaybackInfo.currentBlock; matchFound = TRUE; break; // We've found a match, so don't bother checking other playback entries. } } // If we didn't find a match in our existing list of played files, so add to our list if we have space. if ((!matchFound) && (numberOfPlayedFiles < MAX_FILES) && (strcmp(CurrentPlaybackFile->name,"__temprec__.ts")!=0)) { numberOfPlayedFiles++; // Increase the number of Played Files. playedFiles[numberOfPlayedFiles] = TAP_MemAlloc( sizeof (*playedFiles[numberOfPlayedFiles])); playedFiles[numberOfPlayedFiles]->startCluster = CurrentPlaybackFile->startCluster; // Save the disk start cluster. playedFiles[numberOfPlayedFiles]->currentBlock = CurrentPlaybackInfo.currentBlock; // Save the current block position. playedFiles[numberOfPlayedFiles]->totalBlock = CurrentPlaybackInfo.totalBlock; // Save the total block size. strcpy(playedFiles[numberOfPlayedFiles]->name,CurrentPlaybackFile->name); // Save the file name. playinfoChanged = TRUE; // Set flag so that playback info will get written to disk. } }
char* GetCurrentDir(void) { dword cluster; char* path; TYPE_File file; char* temp; appendToLogfile("GetCurrentDir: started."); path = TAP_MemAlloc (2); if (path == NULL) { appendToLogfile("GetCurrentDir: TAP_MemAlloc (2) failed."); return NULL; } appendToLogfile("GetCurrentDir: after memalloc."); strcpy (path, ""); path[0]='\0'; // while we have a '.' entry we work up the tree matching starting clusters while (CurrentDirStartCluster (&cluster)) { // TYPE_File file; // move into parent directory and look for a starting cluster match TAP_Hdd_ChangeDir (".."); memset (&file, 0, sizeof (file)); if (TAP_Hdd_FindFirst (&file)) { while ((cluster != file.startCluster) && TAP_Hdd_FindNext (&file)) {}; } // if we have a match prepend it to the path if (cluster == file.startCluster) { // char* temp; temp = TAP_MemAlloc (strlen (path) + strlen (file.name) + 2); // no memory - back to starting directory and return NULL if (temp == NULL) { appendToLogfile("GetCurrentDir: TAP_MemAlloc (strlen path) failed."); TAP_Hdd_ChangeDir (file.name); if (strlen (path)) TAP_Hdd_ChangeDir (&path[1]); TAP_MemFree (path); return NULL; } appendStringToLogfile("GetCurrentDir: Match on file=%s",file.name); // There's an issue where we may find the "." directory entry instead of the subdir - // so for now, let's ignore it. 5 Nov 2005 if (strcmp(file.name,".")!=0) { strcpy (temp, "/"); strcat (temp, file.name); strcat (temp, path); TAP_MemFree (path); path = temp; appendStringToLogfile("GetCurrentDir: Path now=%s",path); } } else { // directory structure inconsistent, shouldn't get here // problem - we can't get back to our starting directory TAP_MemFree (path); appendStringToLogfile("GetCurrentDir: Bombed out.",file.name); return NULL; } } if (strlen (path)) { // finally we put ourselves back in our starting directory //TAP_Hdd_ChangeDir (&path[1]); appendToLogfile("GetCurrentDir: Found current directory."); appendStringToLogfile("GetCurrentDir: It's %s.",path); GotoPath(path); } else { // We're at the root strcpy (path, "/"); appendStringToLogfile("GetCurrentDir: Found at ROOT.",file.name); } return (path); }
dword StringDBAdd(tStringDB *StringDB, char *Text) { TRACEENTER(); char *p; dword ret; if(!StringDB || !Text) { TRACEEXIT(); return 0; } p = StringDB->DB; while(p < StringDB->DBEnd) { if(!strcmp(p, Text)) { ret = (dword)p - (dword)StringDB->DB; TRACEEXIT(); return ret; } p += (strlen(p) + 1); } if(((StringDB->DBEnd - StringDB->DB) + strlen(Text) + 2) > StringDB->DBSize) { int NewStringDBSize; char *NewStringDB; if(StringDB->DBSize == 0) NewStringDBSize = 2 * strlen(Text); else NewStringDBSize = StringDB->DBSize + 4096; NewStringDB = TAP_MemAlloc(NewStringDBSize); if(!NewStringDB) { TRACEEXIT(); return 0; } memset(NewStringDB, 0, NewStringDBSize); memcpy(NewStringDB, StringDB->DB, StringDB->DBSize); TAP_MemFree(StringDB->DB); StringDB->DBPtr = StringDB->DBPtr - StringDB->DB + NewStringDB; StringDB->DBEnd = StringDB->DBEnd - StringDB->DB + NewStringDB; StringDB->DB = NewStringDB; StringDB->DBSize = NewStringDBSize; } p = StringDB->DBEnd; strcpy(StringDB->DBEnd, Text); StringDB->DBEnd = StringDB->DBEnd + strlen(Text) + 1; ret = (dword)p - (dword)StringDB->DB; TRACEEXIT(); return ret; }
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(); }