6 static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE
[] = {
7 { VFR_RETURN_SUCCESS
, NULL
},
8 { VFR_RETURN_ERROR_SKIPED
, NULL
},
9 { VFR_RETURN_FATAL_ERROR
, "fatal error!!" },
11 { VFR_RETURN_MISMATCHED
, "unexpected token" },
12 { VFR_RETURN_INVALID_PARAMETER
, "Invalid parameter" },
13 { VFR_RETURN_OUT_FOR_RESOURCES
, "system out of memory" },
14 { VFR_RETURN_UNSUPPORTED
, "unsupported" },
15 { VFR_RETURN_REDEFINED
, "already defined" },
16 { VFR_RETURN_FORMID_REDEFINED
, "form id already defined" },
17 { VFR_RETURN_QUESTIONID_REDEFINED
, "question id already defined" },
18 { VFR_RETURN_VARSTOREID_REDEFINED
, "varstore id already defined" },
19 { VFR_RETURN_UNDEFINED
, "undefined" },
20 { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION
, "some variable has not defined by a question"},
21 { VFR_RETURN_GET_EFIVARSTORE_ERROR
, "get efi varstore error"},
22 { VFR_RETURN_EFIVARSTORE_USE_ERROR
, "can not use the efi varstore like this" },
23 { VFR_RETURN_EFIVARSTORE_SIZE_ERROR
, "unsupport efi varstore size should be <= 8 bytes" },
24 { VFR_RETURN_GET_NVVARSTORE_ERROR
, "get name value varstore error" },
25 { VFR_RETURN_QVAR_REUSE
, "variable reused by more than one question" },
26 { VFR_RETURN_FLAGS_UNSUPPORTED
, "flags unsupported" },
27 { VFR_RETURN_ERROR_ARRARY_NUM
, "array number error" },
28 { VFR_RETURN_DATA_STRING_ERROR
, "data field string error or not support"},
29 { VFR_RETURN_CODEUNDEFINED
, "Undefined Error Code" }
32 CVfrErrorHandle::CVfrErrorHandle (
36 mScopeRecordListHead
= NULL
;
37 mScopeRecordListTail
= NULL
;
38 mVfrErrorHandleTable
= VFR_ERROR_HANDLE_TABLE
;
41 CVfrErrorHandle::~CVfrErrorHandle (
45 SVfrFileScopeRecord
*pNode
= NULL
;
47 while (mScopeRecordListHead
!= NULL
) {
48 pNode
= mScopeRecordListHead
;
49 mScopeRecordListHead
= mScopeRecordListHead
->mNext
;
53 mScopeRecordListHead
= NULL
;
54 mScopeRecordListTail
= NULL
;
55 mVfrErrorHandleTable
= NULL
;
58 SVfrFileScopeRecord::SVfrFileScopeRecord (
64 INT8
*FileName
= NULL
;
67 mWholeScopeLine
= LineNum
;
70 Str
= strchr (Record
, ' ');
71 mScopeLineStart
= atoi (++Str
);
73 Str
= strchr (Str
, '\"');
76 while((Str
= strstr (FileName
, "\\\\")) != NULL
) {
79 if ((mFileName
= new INT8
[strlen(FileName
)]) != NULL
) {
80 for (Index
= 0; FileName
[Index
] != '\"'; Index
++) {
81 mFileName
[Index
] = FileName
[Index
];
83 mFileName
[Index
] = '\0';
89 SVfrFileScopeRecord::~SVfrFileScopeRecord (
93 if (mFileName
!= NULL
) {
99 CVfrErrorHandle::ParseFileScopeRecord (
101 IN UINT32 WholeScopeLine
104 INT8
*FullPathName
= NULL
;
105 SVfrFileScopeRecord
*pNode
= NULL
;
107 if (Record
== NULL
) {
111 if ((pNode
= new SVfrFileScopeRecord(Record
, WholeScopeLine
)) == NULL
) {
115 if (mScopeRecordListHead
== NULL
) {
116 mScopeRecordListTail
= mScopeRecordListHead
= pNode
;
118 mScopeRecordListTail
->mNext
= pNode
;
119 mScopeRecordListTail
= pNode
;
124 CVfrErrorHandle::GetFileNameLineNum (
130 SVfrFileScopeRecord
*pNode
= NULL
;
132 if ((FileName
== NULL
) || (FileLine
== NULL
)) {
137 *FileLine
= 0xFFFFFFFF;
139 for (pNode
= mScopeRecordListHead
; pNode
->mNext
!= NULL
; pNode
= pNode
->mNext
) {
140 if ((LineNum
> pNode
->mWholeScopeLine
) && (pNode
->mNext
->mWholeScopeLine
> LineNum
)) {
141 *FileName
= pNode
->mFileName
;
142 *FileLine
= LineNum
- pNode
->mWholeScopeLine
+ pNode
->mScopeLineStart
- 1;
147 *FileName
= pNode
->mFileName
;
148 *FileLine
= LineNum
- pNode
->mWholeScopeLine
+ pNode
->mScopeLineStart
- 1;
152 CVfrErrorHandle::PrintError (
158 INT8
*FileName
= NULL
;
161 GetFileNameLineNum (LineNum
, &FileName
, &FileLine
);
162 printf ("%s line %d: error %s %s\n", FileName
, FileLine
, TokName
, ErrorMsg
);
166 CVfrErrorHandle::HandleError (
167 IN EFI_VFR_RETURN_CODE ErrorCode
,
173 INT8
*FileName
= NULL
;
175 INT8
*ErrorMsg
= NULL
;
177 if (mVfrErrorHandleTable
== NULL
) {
181 for (Index
= 0; mVfrErrorHandleTable
[Index
].mErrorCode
!= VFR_RETURN_CODEUNDEFINED
; Index
++) {
182 if (ErrorCode
== mVfrErrorHandleTable
[Index
].mErrorCode
) {
183 ErrorMsg
= mVfrErrorHandleTable
[Index
].mErrorMsg
;
188 if (ErrorMsg
!= NULL
) {
189 GetFileNameLineNum (LineNum
, &FileName
, &FileLine
);
190 printf ("%s line %d: error %s %s\n", FileName
, FileLine
, TokName
, ErrorMsg
);
197 CVfrErrorHandle gCVfrErrorHandle
;