EFI_STATUS GetCmdDispatch ( IN CHAR16 *Buffer, OUT EFI_MONITOR_COMMAND *Cmd ) /*++ Routine Description: Find cmd info from input buffer. Arguments: Buffer - Command buffer. Cmd - Pointer to EFI_MONITOR_COMMAND structure. Returns: EFI_SUCCESS - Operation succeeded. EFI_INVALID_PARAMETER - Parameter invalid. EFI_OUT_OF_RESOURCES - Memory allocation failed. EFI_NOT_FOUND - Can't find CmdName. Others - Some failure happened. --*/ { UINTN Index; CHAR16 *BufferTmp; EFI_STATUS Status; CHAR16 *TestNodeName; CHAR16 *TempCmdArg = NULL; if (Cmd == NULL) { EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"Error in GetCmdDisPatch: null Cmd")); return EFI_INVALID_PARAMETER; } // // get cmd name // // // Skip space at the beginning // for (BufferTmp = Buffer; *BufferTmp; BufferTmp++) { if ((*BufferTmp != L' ') && (*BufferTmp != L'\t')) { break; } } if (*BufferTmp == 0) { EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"GetCmdDispatch: Can't find CmdName")); return EFI_NOT_FOUND; } Index = EntsStrStr (BufferTmp, L" "); if (Index == 0) { Index = EntsStrStr (BufferTmp, L"\t"); } // // Copy comd name skipping the space character // if (Index == 0) { Cmd->ComdName = EntsStrDuplicate (BufferTmp); if (Cmd->ComdName == NULL) { EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"GetCmdDispatch: Can't find CmdName")); return EFI_OUT_OF_RESOURCES; } } else { Cmd->ComdName = EntsAllocatePool (Index * 2); if (Cmd->ComdName == NULL) { EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"GetCmdDispatch: EFI_OUT_OF_RESOURCES")); return EFI_OUT_OF_RESOURCES; } SetMem (Cmd->ComdName, Index * 2, 0); CopyMem (Cmd->ComdName, BufferTmp, (Index - 1) * 2); } // // Get Cmd Input // if (StrLen (BufferTmp + StrLen (Cmd->ComdName)) != 0) { TempCmdArg = BufferTmp + StrLen (Cmd->ComdName) + 1; // // Skip ' ' & '\t' letters // for (; *TempCmdArg == L' ' || *TempCmdArg == L'\t'; TempCmdArg++); // // Only pactch TEST_EXEC sct xxx command // if (CompareMem (Cmd->ComdName, EFI_NETWORK_EXEC_COMMAND, StrLen (EFI_NETWORK_EXEC_COMMAND) * 2) == 0 && (TempCmdArg[0] == L's' || TempCmdArg[0] == L'S') && (TempCmdArg[1] == L'c' || TempCmdArg[1] == L'C') && (TempCmdArg[2] == L't' || TempCmdArg[2] == L'T') && (TempCmdArg[3] == L' ' || TempCmdArg[3] == L'\t') && gFT->ConfigData->EnableScreenOutput == FALSE) { // // screen output silent mode, add -v switch // Cmd->ComdArg = (CHAR16 *) AllocateZeroPool(StrSize(TempCmdArg) + StrLen(L" -v")); if ( Cmd->ComdArg == NULL ){ EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"GetCmdDispatch: EFI_OUT_OF_RESOURCES")); return EFI_OUT_OF_RESOURCES; } EntsCopyMem(Cmd->ComdArg, TempCmdArg, StrLen(TempCmdArg) * sizeof(*TempCmdArg)); EntsCopyMem(Cmd->ComdArg + StrLen(TempCmdArg), L" -v", StrSize(L" -v")); } else { Cmd->ComdArg = EntsStrDuplicate (TempCmdArg); if (Cmd->ComdArg == NULL) { EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"GetCmdDispatch: EFI_OUT_OF_RESOURCES")); return EFI_OUT_OF_RESOURCES; } } } // // get the test interface name // TestNodeName = Cmd->ComdName; while (*TestNodeName != 0) { if ((*TestNodeName == L'-') && (*(TestNodeName + 1) == L'>')) { break; } TestNodeName++; } if (*TestNodeName != 0) { // // get it // *TestNodeName = 0; TestNodeName += 2; Cmd->ComdInterface = EntsStrDuplicate (TestNodeName); if (Cmd->ComdInterface == NULL) { EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"GetCmdDispatch: EFI_OUT_OF_RESOURCES")); return EFI_OUT_OF_RESOURCES; } } else { Cmd->ComdInterface = NULL; } // // Find Cmd Type // Status = GetCmdType (Cmd); return Status; }
/** * \brief The actual parsing procedure. * \param reader A pointer to a CBibReader object with the contents of the .aux file. */ void CAuxParser::ParseFile(CBibReader* reader) { _TUCHAR c; xString* cmd = xsNew(); xString* key = xsNew(); CString str; BOOL escape = FALSE; BOOL iscite = FALSE; BOOL isinput = FALSE; BOOL incmd = FALSE; BOOL bibdata = FALSE; BOOL bibstyle = FALSE; BOOL citation = FALSE; while (reader->Read(&c, sizeof(_TUCHAR))) { switch (c) { case _T('\\'): if (!escape) incmd = TRUE; escape = !escape; xsClear(cmd); break; case _T('{'): xsTerminate(cmd); switch (GetCmdType(cmd)) { case CT_BIBCITE: iscite = TRUE; break; case CT_INPUT: isinput = TRUE; break; case CT_BIBDATA: bibdata = TRUE; break; case CT_BIBSTYLE: bibstyle = TRUE; break; case CT_CITATION: citation = TRUE; break; } incmd = FALSE; xsClear(cmd); break; case _T('}'): if (iscite) { xsTerminate(key); m_Keys.AddTail(CString(xsValue(key))); str.Format(AfxLoadString(IDS_STRING_FOUNDKEY), xsValue(key)); AddLog(str); xsClear(key); iscite = FALSE; } else if (citation) { xsTerminate(key); if (xsCompareS(key, _T("*")) == 0) { m_AllItems = TRUE; str.Format(AfxLoadString(IDS_STRING_FOUNDKEY), xsValue(key)); AddLog(str); } xsClear(key); citation = FALSE; } else if (isinput) { // Recursively parse inputed files and search for \citation{*} CAuxParser* parser = new CAuxParser(m_Owner); xsTerminate(key); parser->m_AuxFile = CString(xsValue(key)); parser->Parse(m_LogProc); m_Keys.AddTail(&parser->m_Keys); m_AllItems |= parser->m_AllItems; m_Warnings += parser->m_Warnings; m_Errors += parser->m_Errors; delete parser; xsClear(key); isinput = FALSE; } else if (bibdata) { xsTerminate(key); m_BibData = CString(xsValue(key)); str.Format(AfxLoadString(IDS_STRING_BIBDATA), xsValue(key)); AddLog(str); xsClear(key); bibdata = FALSE; } else if (bibstyle) { xsTerminate(key); m_BibStyle = CString(xsValue(key)); str.Format(AfxLoadString(IDS_STRING_BIBSTYLE), xsValue(key)); AddLog(str); xsClear(key); bibstyle = FALSE; } incmd = FALSE; break; case _T('\r'): case _T('\n'): case _T('\t'): case _T(' '): break; default: if (iscite || isinput || bibdata || bibstyle || citation) xsPut(key, c); else xsPut(cmd, c); } } xsDelete(cmd); xsDelete(key); }