/********************************************************************* Function: open Description: Opens the specified file for the given mode of access *********************************************************************/ static int fss_open(const char *name, int mode) { // Open file u32 namelen; #if defined(_UNICODE_SUPPORT_) ADI_FSS_WCHAR *wname = (ADI_FSS_WCHAR*)AsciiToUnicode(name, &namelen) #else ADI_FSS_WCHAR *wname = (ADI_FSS_WCHAR*)name; namelen = strlen(name); #endif ADI_FSS_FILE_HANDLE FileHandle; u32 result = adi_fss_FileOpen ( wname, namelen, (u32)mode, &FileHandle ); #if defined(_UNICODE_SUPPORT_) // free unicode name adi_fss_free(wname); #endif // error exit if (result) { return -1; } // return FileHandle return (int)FileHandle; }
void PrintGpsText() { if (*g_TimeMs < gGpsTextTimer + GPS_TEXT_TIME) { std::wstring text; if (gCurrentGpsMode == III_RADAR_SPRITE_CENTRE) { text = L"GPS Mode: Disabled"; } else { short legendtext[128]; AsciiToUnicode((char*)BlipsGxtTableIII[gCurrentGpsMode], legendtext); //GetText(TheText, ); text = L"GPS Mode: "; text += (wchar_t*)legendtext; } unsigned int color = 0xFFFFFFFF; SetFontStyle(0); SetScale(0.7f, 1.0f); SetColor(&color); SetJustifyOn(); SetDropShadowPosition(1); SetPropOn(); CVector2D point; point.x = -1.0; point.y = -1.0; TransformRadarPointToScreenSpaceIII(point, point); PrintString(point.x, point.y + 10.0f, (short*)text.c_str()); SetDropShadowPosition(0); SetFontStyle(0); } }
bool iswdigit(const WCHAR ch) { WSTRING wsz; // Any other digits ? AsciiToUnicode("0123456789", wsz); return wsz.find(ch, 0) != WSTRING::npos; }
bool iswspace(const WCHAR ch) { WSTRING wsz; // Any other spaces ? AsciiToUnicode(" \t\r\n", wsz); return wsz.find(ch, 0) != WSTRING::npos; }
/** * Interface to CTestList-derived classes for getting all information about the next test to be run. * * @return * Returns a pointer to a CTestInfo object containing all available information about the next test. */ CTestInfo* CWineTest::GetNextTestInfo() { while(!m_CurrentFile.empty() || GetNextFile()) { try { while(GetNextTest()) { /* If the user specified a test through the command line, check this here */ if(!Configuration.GetTest().empty() && Configuration.GetTest() != m_CurrentTest) continue; { auto_ptr<CTestInfo> TestInfo(new CTestInfo()); size_t UnderscorePosition; /* Build the command line */ TestInfo->CommandLine = m_TestPath; TestInfo->CommandLine += m_CurrentFile; TestInfo->CommandLine += ' '; TestInfo->CommandLine += AsciiToUnicode(m_CurrentTest); /* Store the Module name */ UnderscorePosition = m_CurrentFile.find_last_of('_'); if(UnderscorePosition == m_CurrentFile.npos) { stringstream ss; ss << "Invalid test file name: " << UnicodeToAscii(m_CurrentFile) << endl; SSEXCEPTION; } TestInfo->Module = UnicodeToAscii(m_CurrentFile.substr(0, UnderscorePosition)); /* Store the test */ TestInfo->Test = m_CurrentTest; return TestInfo.release(); } } } catch(CTestException& e) { stringstream ss; ss << "An exception occurred trying to list tests for: " << UnicodeToAscii(m_CurrentFile) << endl; StringOut(ss.str()); StringOut(e.GetMessage()); StringOut("\n"); m_CurrentFile.clear(); delete[] m_ListBuffer; } } return NULL; }
INTN EFIAPI main ( IN INTN Argc, IN CHAR8 **Argv, IN CHAR8 **Envp ) /*++ Routine Description: Main entry point to SEC for WinNt. This is a Windows program Arguments: Argc - Number of command line arguments Argv - Array of command line argument strings Envp - Array of environmemt variable strings Returns: 0 - Normal exit 1 - Abnormal exit --*/ { EFI_STATUS Status; EFI_PHYSICAL_ADDRESS InitialStackMemory; UINT64 InitialStackMemorySize; EFI_BOOT_MODE BootMode; UINTN Index; UINTN Index1; UINTN Index2; UINTN PeiIndex; CHAR8 *MemorySizeStr; CHAR8 *FirmwareVolumesStr; CHAR8 *BootModeStr; CHAR16 *FileName; CHAR8 *FileNameAscii; BOOLEAN Done; VOID *PeiCoreFile; UINTN *StackPointer; printf ("\nEDK SEC Main NT Emulation Environment from www.TianoCore.org\n"); // // Make some Windows calls to Set the process to the highest priority in the // idle class. We need this to have good performance. // SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); // // Set defaults in case we can not find an environment variable // MemorySizeStr = "64"; FirmwareVolumesStr = "..\\Fv\\FvRecovery.fd"; BootModeStr = "0"; // // Parse the environment varialbes for the ones we care about. // for (Index = 0; Envp[Index] != NULL; Index++) { if (strncmp (Envp[Index], EFI_MEMORY_SIZE_STR, sizeof (EFI_MEMORY_SIZE_STR) - 1) == 0) { MemorySizeStr = &Envp[Index][sizeof (EFI_MEMORY_SIZE_STR)]; } if (strncmp (Envp[Index], EFI_FIRMWARE_VOLUMES_STR, sizeof (EFI_FIRMWARE_VOLUMES_STR) - 1) == 0) { FirmwareVolumesStr = &Envp[Index][sizeof (EFI_FIRMWARE_VOLUMES_STR)]; } if (strncmp (Envp[Index], EFI_BOOT_MODE_STR, sizeof (EFI_BOOT_MODE_STR) - 1) == 0) { BootModeStr = &Envp[Index][sizeof (EFI_BOOT_MODE_STR)]; } } // // Allocate space for gSystemMemory Array // gSystemMemoryCount = CountSeperatorsInString (MemorySizeStr, '!') + 1; gSystemMemory = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY)); if (gSystemMemory == NULL) { printf ("ERROR : Can not allocate memory for %s. Exiting.\n", MemorySizeStr); exit (1); } // // Allocate space for gSystemMemory Array // gFdInfoCount = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1; gFdInfo = calloc (gFdInfoCount, sizeof (NT_FD_INFO)); if (gFdInfo == NULL) { printf ("ERROR : Can not allocate memory for %s. Exiting.\n", FirmwareVolumesStr); exit (1); } // // Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION) // BootMode = atoi (BootModeStr); printf (" BootMode 0x%02x\n", BootMode); // // Allocate 128K memory space with ReadWrite and Execute attributes allocated by VirtualAlloc() API. // to emulate temp memory for PEI. On a real platform this would be SRAM, or using the cache as RAM. // Set InitialStackMemory to 0x5aa5 as stack default value. // InitialStackMemory = 0; InitialStackMemorySize = 0x20000; InitialStackMemory = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (InitialStackMemorySize), MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (InitialStackMemory == 0) { printf ("ERROR : Can not allocate enough SecStack space\n"); exit (1); } for (StackPointer = (UINTN*) (UINTN) InitialStackMemory; StackPointer < (UINTN*) ((UINTN)InitialStackMemory + (SIZE_T) InitialStackMemorySize); StackPointer ++) { *StackPointer = 0x5AA55AA5; } printf (" SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize); // // Open All the firmware volumes and remember the info in the gFdInfo global // for (Done = FALSE, Index = 0, PeiIndex = 0, PeiCoreFile = NULL; !Done; Index++) { FileNameAscii = FirmwareVolumesStr; for (Index1 = 0; (FirmwareVolumesStr[Index1] != '!') && (FirmwareVolumesStr[Index1] != 0); Index1++) ; if (FirmwareVolumesStr[Index1] == 0) { Done = TRUE; } else { FirmwareVolumesStr[Index1] = '\0'; FirmwareVolumesStr = FirmwareVolumesStr + Index1 + 1; } // // Convert Ascii string to Unicode string // FileName = AsciiToUnicode (FileNameAscii, NULL); // // Open the FD and remmeber where it got mapped into our processes address space // Status = WinNtOpenFile ( FileName, 0, OPEN_EXISTING, &gFdInfo[Index].Address, &gFdInfo[Index].Size ); if (EFI_ERROR (Status)) { printf ("ERROR : Can not open Firmware Device File %S (%r). Exiting.\n", FileName, Status); exit (1); } printf (" FD loaded from"); // // printf can't print filenames directly as the \ gets interperted as an // escape character. // for (Index2 = 0; FileName[Index2] != '\0'; Index2++) { printf ("%c", FileName[Index2]); } free (FileName); if (PeiCoreFile == NULL) { // // Assume the beginning of the FD is an FV and look for the PEI Core. // Load the first one we find. // Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile); if (!EFI_ERROR (Status)) { PeiIndex = Index; printf (" contains SEC Core"); } } printf ("\n"); } // // Calculate memory regions and store the information in the gSystemMemory // global for later use. The autosizing code will use this data to // map this memory into the SEC process memory space. // for (Index = 0, Done = FALSE; !Done; Index++) { // // Save the size of the memory // gSystemMemory[Index].Size = atoi (MemorySizeStr) * 0x100000; // // Find the next region // for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++) ; if (MemorySizeStr[Index1] == 0) { Done = TRUE; } MemorySizeStr = MemorySizeStr + Index1 + 1; } printf ("\n"); // // Hand off to PEI Core // SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, PeiCoreFile); // // If we get here, then the PEI Core returned. This is an error as PEI should // always hand off to DXE. // printf ("ERROR : PEI Core returned\n"); exit (1); }
bool iswxdigit(const WCHAR ch) { WSTRING wsz; AsciiToUnicode("0123456789abcdefABCDEF", wsz); return wsz.find(ch, 0) != WSTRING::npos; }
void PrintGpsText() { unsigned int color; CVector2D point; short text[128]; if(*g_TimeMs < gGpsTextTimer + GPS_TEXT_TIME) { switch(gCurrentGpsMode) { case GPS_MODE_DISABLED: AsciiToUnicode("GPS Mode: Disabled", text); break; case GPS_MODE_DEFAULT: AsciiToUnicode("GPS Mode: Default", text); break; case GPS_MODE_AMMUNATION: if(*gCurrLevel != LEVEL_SHORESIDE) AsciiToUnicode("GPS Mode: Ammu-Nation", text); else AsciiToUnicode("GPS Error: can't find Ammu-Nation", text); break; case GPS_MODE_BOMBSHOP: AsciiToUnicode("GPS Mode: Bomb Shop", text); break; case GPS_MODE_FIRESTATION: AsciiToUnicode("GPS Mode: Fire Station", text); break; case GPS_MODE_HOSPITAL: AsciiToUnicode("GPS Mode: Hospital", text); break; case GPS_MODE_PAYNSPRAY: AsciiToUnicode("GPS Mode: Pay'N'Spray", text); break; case GPS_MODE_POLICE: AsciiToUnicode("GPS Mode: Police", text); break; case GPS_MODE_SAFEHOUSE: AsciiToUnicode("GPS Mode: Safehouse", text); break; default: AsciiToUnicode("GPS Error: Unknown command", text); } color = 0xFFFFFFFF; SetFontStyle(0); SetScale(0.7f, 1.0f); SetColor(&color); SetJustifyOn(); SetDropShadowPosition(1); SetPropOn(); point.x = -1.0f; point.y = -1.0f; TransformRadarPointToScreenSpace(point, point); PrintString(point.x, point.y + 10.0f, text); SetDropShadowPosition(0); SetFontStyle(0); } }
//***************************************************************************** bool CHTMLWidget::Parse( //Parse text buffer and add child widgets for each part. // //Params: const CStretchyBuffer &text) //(in) Text to parse. // //Returns: True if parse was successful, false if there was a parse error. { //Renderer init. ClearChildren(); this->wCurrentColumn = this->wX = 0; this->wY = this->wMargin; this->bSkipSpace = true; this->dwCurrentLinkTag = this->dwLinkTagStart; for (int i = First_Tag; i <= Tag_Count; ++i) // Including unknown aeTagLevel[i] = 0; mIdmap.clear(); static const WCHAR defaultColor[] = {We('F'),We('F'),We('F'),We('F'),We('F'),We('F'),We(0)}; this->wstrBGColor = defaultColor; //Parser init. XML_Parser parser = XML_ParserCreate(NULL); XML_SetUserData(parser, this); XML_SetElementHandler(parser, StartElement_cb, EndElement_cb); XML_SetCharacterDataHandler(parser, InElement_cb); // XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_NEVER); bool bResult = true; char *buf = (char*)(BYTE*)text; //size - 2 seems to fix "invalid token" errors at EOF (even at empty files). const UINT size = text.Size() - 2; //Parse the XML. static const char entities[] = "<?xml version=\"1.0\" encoding=\"" "UTF-8" "\"?>" "<!DOCTYPE html [" "<!ENTITY nbsp \"\xc2\xa0\">" //utf-8 for 0xa0 = unicode nbsp "]>"; if ((XML_Parse(parser, entities, strlen(entities), false) == XML_STATUS_ERROR) || (XML_Parse(parser, buf, size, true) == XML_STATUS_ERROR)) { //Some problem occurred. char errorStr[256]; _snprintf(errorStr, 256, "HTML Parse Error: %s at line %u:%u" NEWLINE, XML_ErrorString(XML_GetErrorCode(parser)), (UINT)XML_GetCurrentLineNumber(parser), (UINT)XML_GetCurrentColumnNumber(parser)); CFiles Files; Files.AppendErrorLog((char *)errorStr); #ifdef RUSSIAN_BUILD //Fix unsupported KOI8 encoded Cyrillic chars. // ConvertCyrillicEncodedXMLToUTF8(text); #endif AsciiToUnicode(errorStr, this->wstrStatus); bResult = false; } //Parser clean-up. XML_ParserFree(parser); NewLine(); //once done, ensure final line of text is included in height NewLine(true); //...and have a blank line at the bottom to look good //Render surface to display on screen. bool bCanResize = CanResize(); if (bCanResize) { this->pParent->ScrollAbsolute(0, 0); //scroll to top of page if (this->wY < this->pParent->GetH()) //stretch surface to fill container this->wY = this->pParent->GetH(); } UpdateHTMLSurface(); //Resize (if possible). if (bCanResize) Resize(this->pHTMLSurface->w, this->pHTMLSurface->h); return bResult; }
/** * Converts an ASCII string to a Unicode one. * * @param AsciiString * Pointer to a std::string containing the ASCII string * * @return * The Unicode string as std::wstring */ wstring AsciiToUnicode(const string& AsciiString) { return AsciiToUnicode(AsciiString.c_str()); }