//------------ // void TerminateRoutine( void ) // Performs the clean-up and terminate TAP { if(schDispSaveToFile == TRUE) { schWriteSearchList(); } TerminateMenu(); TerminateConfigMenu(); ReleaseLogoMemory(); // clean-up logo routines ExitRoutine(); TAP_MemFree(schLcnToServiceTv); TAP_MemFree(schLcnToServiceRadio); if( schEpgData ) { TAP_MemFree( schEpgData ); } if( schEpgDataExtendedInfo ) { TAP_MemFree( schEpgDataExtendedInfo ); } if( schConflictEpgData ) { TAP_MemFree( schConflictEpgData ); } freeAllReservedMemoryForLanguage(); TAP_Exit(); // exit }
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 ReleaseLogoMemory() { int i; for ( i=0; i<=maxTvSvc; i++) { TAP_MemFree( logoArrayTv[i].logo ); } for ( i=0; i<=maxRadioSvc; i++) { TAP_MemFree( logoArrayRadio[i].logo ); } }
//---------------- // void WriteDatFile( TYPE_File *writeFile ) { char* currentDir; appendToLogfile("WriteDatFile: Started.", INFO); appendToLogfile("WriteDatFile: GetCurrentDir called.", WARNING); currentDir = GetCurrentDir(); // Store the current directory. appendStringToLogfile("WriteDatFile: GetCurrentDir returned=%s.",currentDir, WARNING); appendStringToLogfile("WriteDatFile: Moving to=%s.",TAPIniDir, WARNING); GotoPath(TAPIniDir); // Go to the Project Directory. if ( TAP_Hdd_Exist( PLAYDATA_FILENAME ) ) TAP_Hdd_Delete( PLAYDATA_FILENAME ); // Just delete any old copies appendToLogfile("WriteDatFile: Creating DATA file.", ERR); TAP_Hdd_Create( PLAYDATA_FILENAME, ATTR_PROGRAM ); // Create the file appendToLogfile("WriteDatFile: Opening DATA file.", ERR); writeFile = TAP_Hdd_Fopen( PLAYDATA_FILENAME ); if ( writeFile == NULL ) return; // Check we can open it appendToLogfile("WriteDatFile: Writing to DATA file.", ERR); TAP_Hdd_Fwrite( playDataBuffer_ini, PLAYBACKDATA_BUFFER_SIZE_ini, 1, writeFile ); // dump the whole buffer in one hit appendToLogfile("WriteDatFile: Closing DATA file.", ERR); TAP_Hdd_Fclose( writeFile ); appendStringToLogfile("WriteDatFile: Returning to=%s.",currentDir, WARNING); GotoPath(currentDir); // Return to the original directory. TAP_MemFree( currentDir ); // Free allocated memory. appendToLogfile("WriteDatFile: Finished.", INFO); }
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); }
void OSDMenuMessageBoxDestroyNoOSDUpdate(void) { TRACEENTER(); tOSDMapInfo *OSDMapInfo; if(MessageBoxOSDRgn) { TAP_Osd_Delete(MessageBoxOSDRgn); MessageBoxOSDRgn = 0; if(InfoBoxSaveArea) { if(MyOSDRgn) { OSDMapInfo = (tOSDMapInfo*) FIS_vOsdMap(); if(OSDMapInfo) TAP_Osd_RestoreBox(MyOSDRgn, InfoBoxSaveAreaX - OSDMapInfo[MyOSDRgn].x, InfoBoxSaveAreaY - OSDMapInfo[MyOSDRgn].y, _InfoBox_Gd.width, _InfoBox_Gd.height, InfoBoxSaveArea); } else if(OSDRgn) TAP_Osd_RestoreBox(OSDRgn, InfoBoxSaveAreaX, InfoBoxSaveAreaY, _InfoBox_Gd.width, _InfoBox_Gd.height, InfoBoxSaveArea); TAP_MemFree(InfoBoxSaveArea); InfoBoxSaveArea = NULL; MyOSDRgn = 0; } } OSDMenuFreeStdFonts(); TRACEEXIT(); }
TYPE_TapEvent *GetCurrentEvent(int *nCurEvent) { TRACEENTER(); TYPE_TapEvent *evtInfo; unsigned int eventNum, i; int svcType, svcNum; TAP_Channel_GetCurrent(&svcType, &svcNum); evtInfo = TAP_GetEvent(svcType, svcNum, &eventNum); if(evtInfo) { for(i = 0; i < eventNum; i++) { if(evtInfo[i].runningStatus == 4) { if(nCurEvent) *nCurEvent = i; return evtInfo; } } } if(evtInfo) TAP_MemFree(evtInfo); TRACEEXIT(); return NULL; }
void DialogWindowHide (void) { if (!FBDialogWindow || !FBDialogWindow->isVisible || !FBDialogProfile) return; if (FBDialogWindow->Multiple) { if (FBDialogWindow->MultipleOSDSaveBox) { TAP_Osd_RestoreBox (FBDialogWindow->OSDRgn, 0, 0, GetOSDRegionWidth(FBDialogWindow->OSDRgn), GetOSDRegionHeight(FBDialogWindow->OSDRgn), FBDialogWindow->MultipleOSDSaveBox); TAP_MemFree (FBDialogWindow->MultipleOSDSaveBox); FBDialogWindow->MultipleOSDSaveBox = NULL; } FreeOSDRegion(FBDialogWindow->OSDRgn); // doesn't wipe out } else { DialogWindowAlpha(0); TAP_Osd_FillBox (FBDialogWindow->OSDRgn, 0, 0, FBDialogWindow->OSDWidth, FBDialogWindow->OSDHeight, 0); TAP_Osd_SetTransparency (FBDialogWindow->OSDRgn, 255); TAP_Osd_Delete (FBDialogWindow->OSDRgn); } FBDialogWindow->OSDRgn = 0; FBDialogWindow->isVisible = FALSE; if (FBDialogWindow->isNormalMode) TAP_EnterNormal(); }
void BitmapPage::OnClose() { int x = (MAX_SCREEN_X - width) / 2; int y = (MAX_SCREEN_Y - height) / 2; TAP_Osd_RestoreBox(GetTAPScreenRegion(), x,y, width,height, windowCopy); TAP_MemFree(windowCopy); }
void IMEM_Kill( void ) { if( isInitialized && imem.pHeap ) { TAP_MemFree( imem.pHeap ); memset( &imem, 0, sizeof(imem) ); isInitialized = FALSE; } }
void FM_FreeFontFile(tFontData *FontData) { TRACEENTER(); TAP_MemFree(FontData->pFontData); memset(FontData, 0, sizeof(tFontData)); TRACEEXIT(); }
// Routine to handle the closing of the timer window void ThreeOption_Deactivate( int option ){ ThreeOption_Active = FALSE; // Restore what we had drawn over TAP_Osd_RestoreBox(ThreeOption_RGN, ThreeOption_X, ThreeOption_Y, ThreeOption_W, ThreeOption_H, ThreeOption_Base); TAP_MemFree(ThreeOption_Base); ThreeOption_Base = NULL; ThreeOption_MemFree(); ThreeOption_Callback(option); }
//----------------------------------------------------------------------- // void CloseYesNoWindow(void) { yesnoWindowShowing = FALSE; TAP_Osd_RestoreBox(rgn, YESNO_WINDOW_X, YESNO_WINDOW_Y, YESNO_WINDOW_W, YESNO_WINDOW_H, YesNoWindowCopy); TAP_MemFree(YesNoWindowCopy); YesNoCallback( YesNoResult ); }
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 YesNoBox::OnClose() { TAP_Osd_RestoreBox(GetTAPScreenRegion(), YESNO_WINDOW_X, YESNO_WINDOW_Y, YESNO_WINDOW_W, YESNO_WINDOW_H, windowCopy); TAP_MemFree(windowCopy); if ( _callback && result ) { // commented out as it doesn't work at the moment _callback( result ); } }
void EPGInfo_Free(void) { TRACEENTER(); EPGInfo_DestroyCache(); TAP_MemFree(EPGFilter.GenreArray); memset(&EPGFilter, 0, sizeof(EPGFilter)); TRACEEXIT(); }
void LogoManager_Cleanup(void) { TRACEENTER(); int i; if(LogoManager_LogoData) { for(i = 0; i < LogoManager_NrLogos; i++) TAP_MemFree(LogoManager_LogoData[i].grData); TAP_MemFree(LogoManager_LogoData); } LogoManager_LogoData = NULL; LogoManager_NrLogos = 0; LogoManager_LUTInitialized = FALSE; TRACEEXIT(); }
//----------------------------------------------------------------------- // void CloseArchiveMoveWindow(void) { int index; appendToLogfile("CloseArchiveMoveWindow: Started.", INFO); moveWindowShowing = FALSE; TAP_Osd_RestoreBox(rgn, MOVE_WINDOW_X, MOVE_WINDOW_Y, MOVE_WINDOW_W, MOVE_WINDOW_H, moveWindowCopy); TAP_MemFree(moveWindowCopy); // Free memory allocated to storing old screen area. TAP_Osd_Delete(moveRgn); // Free memory allocated to virtual screen area. // Release any memory allocated to the "moveFiles" array. for ( index=1; index<=numberOfDestinationFolders ; index++) { if (moveFiles[index] != NULL) { TAP_MemFree(moveFiles[index]); // Free any previously allocated memory moveFiles[index] = NULL; // Set the pointer to NULL so that it's all cleared. } } appendToLogfile("CloseArchiveMoveWindow: Finished.", INFO); }
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 }
void KeyDestroy( keyCodes_Struct *keyCodes ) { int i; if ( keyCodes->count == 0 ) return; // bounds check for ( i=1; i <= (keyCodes->count) ; i++ ) // for all members of the structure { TAP_MemFree( keyCodes->keys[i] ); // release memory back to the heap } keyCodes->count = 0; // tidy things up - set number of elements to 0 }
// Routine to handle the closing of the timer window void GuideSortOrder_Deactivate( bool yes ){ GuideSortOrder_Active = FALSE; // Restore what we had drawn over TAP_Osd_RestoreBox(GuideSortOrder_RGN, GuideSortOrder_X, GuideSortOrder_Y, GuideSortOrder_W, GuideSortOrder_H, GuideSortOrder_Base); TAP_MemFree(GuideSortOrder_Base); GuideSortOrder_Base = NULL; GuideSortOrder_MemFree(); if( yes ){ GuideSortOrder_Callback(TRUE, GuideSortOrder_Selected); } else { GuideSortOrder_Callback(FALSE, GuideSortOrder_Selected); } }
void MenuDestroy( menu_Struct *menu ) { int i; if ( menu->count == 0 ) return; // bounds check for ( i=1; i <= (menu->count) ; i++ ) // for all members of the structure { TAP_MemFree( menu->items[i] ); // release memory back to the heap } menu->count = 0; // tidy things up - set number of elements to 0 }
bool HDD_FindMountPointDevice(char *File, char *MountPoint, char *MountDevice) { TRACEENTER(); struct mntent *ent; FILE *aFile; char AbsFile[FBLIB_DIR_SIZE], Root[FBLIB_DIR_SIZE], Dev[FBLIB_DIR_SIZE]; char *x; Root[0] = '\0'; Dev[0] = '\0'; AbsFile[0] = '\0'; ConvertPathType(File, AbsFile, PF_LinuxPathOnly); if(*AbsFile) { aFile = setmntent("/proc/mounts", "r"); if(aFile != NULL) { while(NULL != (ent = getmntent(aFile))) { x = ansicstr(ent->mnt_dir, strlen(ent->mnt_dir), 0, NULL, NULL); if(x) { if((strstr(AbsFile, x) == AbsFile) && (strlen(x) > strlen(Root))) { strcpy(Root, x); strcpy(Dev, ent->mnt_fsname); } TAP_MemFree(x); } else if((strstr(AbsFile, ent->mnt_dir) == AbsFile) && (strlen(ent->mnt_dir) > strlen(Root))) { strcpy(Root, ent->mnt_dir); strcpy(Dev, ent->mnt_fsname); } } endmntent(aFile); } } if(*Root && (Root[strlen(Root) - 1] != '/')) strcat(Root, "/"); if(*Dev && (Dev[strlen(Dev) - 1] != '/')) strcat(Dev, "/"); if(MountPoint) strcpy(MountPoint, Root); if(MountDevice) strcpy(MountDevice, Dev); TRACEEXIT(); return (Root[0] != '\0' || Dev[0] != '\0'); }
void ELFCleanup(void) { TRACEENTER(); if(fTAP) { close(fTAP); fTAP = 0; } if(ELFHeader) { TAP_MemFree(ELFHeader); ELFHeader = NULL; } if(SectionHeaders) { TAP_MemFree(SectionHeaders); SectionHeaders = NULL; } if(shstrtab) { TAP_MemFree(shstrtab); shstrtab = NULL; } if(strtab) { TAP_MemFree(strtab); strtab = NULL; } TRACEEXIT(); }
void ShowMessageWin( word msgRgn, char* msg1, char* msg2, char* msg3, int delay ) { byte* msgWindowCopy; // Save the region where we are about to display the pop-up. msgWindowCopy = TAP_Osd_SaveBox(msgRgn, MSG_SCREEN_X, MSG_SCREEN_Y, MSG_SCREEN_W, MSG_SCREEN_H); ShowMessageBox(msgRgn, msg1, msg2, msg3 ); TAP_Delay( delay ); TAP_Osd_RestoreBox(msgRgn, MSG_SCREEN_X, MSG_SCREEN_Y, MSG_SCREEN_W, MSG_SCREEN_H, msgWindowCopy); TAP_MemFree(msgWindowCopy); }
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(); }
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 OSDMenuPop(void) { TRACEENTER(); if(CurrentMenuLevel == 0) { TRACEEXIT(); return FALSE; } if(Menu[CurrentMenuLevel].Item) { TAP_MemFree(Menu[CurrentMenuLevel].Item); Menu[CurrentMenuLevel].Item = NULL; } CurrentMenuLevel--; TRACEEXIT(); return TRUE; }
bool StrMkISO(byte *SourceString) { TRACEENTER(); byte *_isostring; bool hasAnsiChars, hasUTFChars; if(!SourceString) { TRACEEXIT(); return FALSE; } if(!*SourceString) { TRACEEXIT(); return TRUE; } GetStringEncoding(SourceString, &hasAnsiChars, &hasUTFChars); if(!hasAnsiChars && hasUTFChars) { StrToISOAlloc(SourceString, &_isostring); if(_isostring) { strcpy(SourceString, _isostring); TAP_MemFree(_isostring); } else { TRACEEXIT(); return FALSE; } } TRACEEXIT(); return TRUE; }
void CallTraceComment(char *Comment) { char Spaces[101]; byte *ISOText; if(Comment) { if(!CallTraceInitialized) CallTraceInit(); Spaces[0] = '\0'; if(CallTraceEnabled) { memset(Spaces, ' ', CallLevel < 50 ? CallLevel << 1 : 100); Spaces[CallLevel < CTSTACKSIZE ? CallLevel << 1 : 100] = '\0'; StrToISOAlloc(Comment, &ISOText); if(ISOText && *ISOText) TAP_PrintNet("%s# %s\n", Spaces, ISOText); TAP_MemFree(ISOText); } } }