]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/EfiUtilityMsgs.c
0e7608d1cfbd2d5218442b4b23521153e0d4c73b
[mirror_edk2.git] / BaseTools / Source / C / Common / EfiUtilityMsgs.c
1 /** @file
2
3 Copyright (c) 2004 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 EfiUtilityMsgs.c
15
16 Abstract:
17
18 EFI tools utility functions to display warning, error, and informational
19 messages.
20
21 --*/
22
23 #include <stdio.h>
24 #include <string.h>
25 #include <ctype.h>
26 #include <stdarg.h>
27 #include <time.h>
28
29 #include "EfiUtilityMsgs.h"
30
31 //
32 // Declare module globals for keeping track of the the utility's
33 // name and other settings.
34 //
35 STATIC STATUS mStatus = STATUS_SUCCESS;
36 STATIC CHAR8 mUtilityName[50] = { 0 };
37 STATIC UINT64 mPrintLogLevel = INFO_LOG_LEVEL;
38 STATIC CHAR8 *mSourceFileName = NULL;
39 STATIC UINT32 mSourceFileLineNum = 0;
40 STATIC UINT32 mErrorCount = 0;
41 STATIC UINT32 mWarningCount = 0;
42 STATIC UINT32 mMaxErrors = 0;
43 STATIC UINT32 mMaxWarnings = 0;
44 STATIC UINT32 mMaxWarningsPlusErrors = 0;
45 STATIC INT8 mPrintLimitsSet = 0;
46
47 STATIC
48 VOID
49 PrintLimitExceeded (
50 VOID
51 );
52
53 VOID
54 Error (
55 CHAR8 *FileName,
56 UINT32 LineNumber,
57 UINT32 MessageCode,
58 CHAR8 *Text,
59 CHAR8 *MsgFmt,
60 ...
61 )
62 /*++
63
64 Routine Description:
65 Prints an error message.
66
67 Arguments:
68 All arguments are optional, though the printed message may be useless if
69 at least something valid is not specified.
70
71 FileName - name of the file or application. If not specified, then the
72 utilty name (as set by the utility calling SetUtilityName()
73 earlier) is used. Otherwise "Unknown utility" is used.
74
75 LineNumber - the line number of error, typically used by parsers. If the
76 utility is not a parser, then 0 should be specified. Otherwise
77 the FileName and LineNumber info can be used to cause
78 MS Visual Studio to jump to the error.
79
80 MessageCode - an application-specific error code that can be referenced in
81 other documentation.
82
83 Text - the text in question, typically used by parsers.
84
85 MsgFmt - the format string for the error message. Can contain formatting
86 controls for use with the varargs.
87
88 Returns:
89 None.
90
91 Notes:
92 We print the following (similar to the Warn() and Debug()
93 W
94 Typical error/warning message format:
95
96 bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters
97
98 BUGBUG -- these three utility functions are almost identical, and
99 should be modified to share code.
100
101 Visual Studio does not find error messages with:
102
103 " error :"
104 " error 1:"
105 " error c1:"
106 " error 1000:"
107 " error c100:"
108
109 It does find:
110 " error c1000:"
111 --*/
112 {
113 va_list List;
114 //
115 // If limits have been set, then check that we have not exceeded them
116 //
117 if (mPrintLimitsSet) {
118 //
119 // See if we've exceeded our total count
120 //
121 if (mMaxWarningsPlusErrors != 0) {
122 if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
123 PrintLimitExceeded ();
124 return ;
125 }
126 }
127 //
128 // See if we've exceeded our error count
129 //
130 if (mMaxErrors != 0) {
131 if (mErrorCount > mMaxErrors) {
132 PrintLimitExceeded ();
133 return ;
134 }
135 }
136 }
137
138 mErrorCount++;
139 va_start (List, MsgFmt);
140 PrintMessage ("ERROR", FileName, LineNumber, MessageCode, Text, MsgFmt, List);
141 va_end (List);
142 }
143
144 VOID
145 ParserError (
146 UINT32 MessageCode,
147 CHAR8 *Text,
148 CHAR8 *MsgFmt,
149 ...
150 )
151 /*++
152
153 Routine Description:
154 Print a parser error, using the source file name and line number
155 set by a previous call to SetParserPosition().
156
157 Arguments:
158 MessageCode - application-specific error code
159 Text - text to print in the error message
160 MsgFmt - format string to print at the end of the error message
161
162 Returns:
163 NA
164
165 --*/
166 {
167 va_list List;
168 //
169 // If limits have been set, then check them
170 //
171 if (mPrintLimitsSet) {
172 //
173 // See if we've exceeded our total count
174 //
175 if (mMaxWarningsPlusErrors != 0) {
176 if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
177 PrintLimitExceeded ();
178 return ;
179 }
180 }
181 //
182 // See if we've exceeded our error count
183 //
184 if (mMaxErrors != 0) {
185 if (mErrorCount > mMaxErrors) {
186 PrintLimitExceeded ();
187 return ;
188 }
189 }
190 }
191
192 mErrorCount++;
193 va_start (List, MsgFmt);
194 PrintMessage ("ERROR", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);
195 va_end (List);
196 }
197
198 VOID
199 ParserWarning (
200 UINT32 ErrorCode,
201 CHAR8 *OffendingText,
202 CHAR8 *MsgFmt,
203 ...
204 )
205 /*++
206
207 Routine Description:
208 Print a parser warning, using the source file name and line number
209 set by a previous call to SetParserPosition().
210
211 Arguments:
212 ErrorCode - application-specific error code
213 OffendingText - text to print in the warning message
214 MsgFmt - format string to print at the end of the warning message
215
216 Returns:
217 NA
218
219 --*/
220 {
221 va_list List;
222 //
223 // If limits have been set, then check them
224 //
225 if (mPrintLimitsSet) {
226 //
227 // See if we've exceeded our total count
228 //
229 if (mMaxWarningsPlusErrors != 0) {
230 if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
231 PrintLimitExceeded ();
232 return ;
233 }
234 }
235 //
236 // See if we've exceeded our warning count
237 //
238 if (mMaxWarnings != 0) {
239 if (mWarningCount > mMaxWarnings) {
240 PrintLimitExceeded ();
241 return ;
242 }
243 }
244 }
245
246 mWarningCount++;
247 va_start (List, MsgFmt);
248 PrintMessage ("WARNING", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);
249 va_end (List);
250 //
251 // Don't set warning status accordingly
252 //
253 // if (mStatus < STATUS_WARNING) {
254 // mStatus = STATUS_WARNING;
255 // }
256 }
257
258 VOID
259 Warning (
260 CHAR8 *FileName,
261 UINT32 LineNumber,
262 UINT32 MessageCode,
263 CHAR8 *Text,
264 CHAR8 *MsgFmt,
265 ...
266 )
267 /*++
268
269 Routine Description:
270 Print a warning message.
271
272 Arguments:
273 FileName - name of the file where the warning was detected, or the name
274 of the application that detected the warning
275
276 LineNumber - the line number where the warning was detected (parsers).
277 0 should be specified if the utility is not a parser.
278
279 MessageCode - an application-specific warning code that can be referenced in
280 other documentation.
281
282 Text - the text in question (parsers)
283
284 MsgFmt - the format string for the warning message. Can contain formatting
285 controls for use with varargs.
286
287 Returns:
288 None.
289
290 --*/
291 {
292 va_list List;
293
294 //
295 // Current Print Level not output warning information.
296 //
297 if (WARNING_LOG_LEVEL < mPrintLogLevel) {
298 return;
299 }
300 //
301 // If limits have been set, then check them
302 //
303 if (mPrintLimitsSet) {
304 //
305 // See if we've exceeded our total count
306 //
307 if (mMaxWarningsPlusErrors != 0) {
308 if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
309 PrintLimitExceeded ();
310 return ;
311 }
312 }
313 //
314 // See if we've exceeded our warning count
315 //
316 if (mMaxWarnings != 0) {
317 if (mWarningCount > mMaxWarnings) {
318 PrintLimitExceeded ();
319 return ;
320 }
321 }
322 }
323
324 mWarningCount++;
325 va_start (List, MsgFmt);
326 PrintMessage ("WARNING", FileName, LineNumber, MessageCode, Text, MsgFmt, List);
327 va_end (List);
328 }
329
330 VOID
331 DebugMsg (
332 CHAR8 *FileName,
333 UINT32 LineNumber,
334 UINT64 MsgLevel,
335 CHAR8 *Text,
336 CHAR8 *MsgFmt,
337 ...
338 )
339 /*++
340
341 Routine Description:
342 Print a Debug message.
343
344 Arguments:
345 FileName - typically the name of the utility printing the debug message, but
346 can be the name of a file being parsed.
347
348 LineNumber - the line number in FileName (parsers)
349
350 MsgLevel - Debug message print level (0~9)
351
352 Text - the text in question (parsers)
353
354 MsgFmt - the format string for the debug message. Can contain formatting
355 controls for use with varargs.
356
357 Returns:
358 None.
359
360 --*/
361 {
362 va_list List;
363 //
364 // If the debug level is less than current print level, then do nothing.
365 //
366 if (MsgLevel < mPrintLogLevel) {
367 return ;
368 }
369
370 va_start (List, MsgFmt);
371 PrintMessage ("DEBUG", FileName, LineNumber, 0, Text, MsgFmt, List);
372 va_end (List);
373 }
374
375 VOID
376 PrintMessage (
377 CHAR8 *Type,
378 CHAR8 *FileName,
379 UINT32 LineNumber,
380 UINT32 MessageCode,
381 CHAR8 *Text,
382 CHAR8 *MsgFmt,
383 va_list List
384 )
385 /*++
386
387 Routine Description:
388 Worker routine for all the utility printing services. Prints the message in
389 a format that Visual Studio will find when scanning build outputs for
390 errors or warnings.
391
392 Arguments:
393 Type - "warning" or "error" string to insert into the message to be
394 printed. The first character of this string (converted to uppercase)
395 is used to preceed the MessageCode value in the output string.
396
397 FileName - name of the file where the warning was detected, or the name
398 of the application that detected the warning
399
400 LineNumber - the line number where the warning was detected (parsers).
401 0 should be specified if the utility is not a parser.
402
403 MessageCode - an application-specific warning code that can be referenced in
404 other documentation.
405
406 Text - part of the message to print
407
408 MsgFmt - the format string for the message. Can contain formatting
409 controls for use with varargs.
410 List - the variable list.
411
412 Returns:
413 None.
414
415 Notes:
416 If FileName == NULL then this utility will use the string passed into SetUtilityName().
417
418 LineNumber is only used if the caller is a parser, in which case FileName refers to the
419 file being parsed.
420
421 Text and MsgFmt are both optional, though it would be of little use calling this function with
422 them both NULL.
423
424 Output will typically be of the form:
425 <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>
426
427 Parser (LineNumber != 0)
428 VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters
429 Generic utility (LineNumber == 0)
430 UtilityName : error E1234 : Text string : MsgFmt string and args
431
432 --*/
433 {
434 CHAR8 Line[MAX_LINE_LEN];
435 CHAR8 Line2[MAX_LINE_LEN];
436 CHAR8 *Cptr;
437 struct tm *NewTime;
438 time_t CurrentTime;
439
440 //
441 // init local variable
442 //
443 Line[0] = '\0';
444 Line2[0] = '\0';
445
446 //
447 // If given a filename, then add it (and the line number) to the string.
448 // If there's no filename, then use the program name if provided.
449 //
450 if (FileName != NULL) {
451 Cptr = FileName;
452 } else {
453 Cptr = NULL;
454 }
455
456 if (strcmp (Type, "DEBUG") == 0) {
457 //
458 // Debug Message requires current time.
459 //
460 time (&CurrentTime);
461 NewTime = localtime (&CurrentTime);
462 fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d",
463 NewTime->tm_year + 1900,
464 NewTime->tm_mon + 1,
465 NewTime->tm_mday,
466 NewTime->tm_hour,
467 NewTime->tm_min,
468 NewTime->tm_sec
469 );
470 if (Cptr != NULL) {
471 sprintf (Line, ": %s", Cptr);
472 if (LineNumber != 0) {
473 sprintf (Line2, "(%u)", (unsigned) LineNumber);
474 strcat (Line, Line2);
475 }
476 }
477 } else {
478 //
479 // Error and Warning Information.
480 //
481 if (Cptr != NULL) {
482 if (mUtilityName[0] != '\0') {
483 fprintf (stdout, "%s...\n", mUtilityName);
484 }
485 sprintf (Line, "%s", Cptr);
486 if (LineNumber != 0) {
487 sprintf (Line2, "(%u)", (unsigned) LineNumber);
488 strcat (Line, Line2);
489 }
490 } else {
491 if (mUtilityName[0] != '\0') {
492 sprintf (Line, "%s", mUtilityName);
493 }
494 }
495
496 if (strcmp (Type, "ERROR") == 0) {
497 //
498 // Set status accordingly for ERROR information.
499 //
500 if (mStatus < STATUS_ERROR) {
501 mStatus = STATUS_ERROR;
502 }
503 }
504 }
505
506 //
507 // Have to print an error code or Visual Studio won't find the
508 // message for you. It has to be decimal digits too.
509 //
510 if (MessageCode != 0) {
511 sprintf (Line2, ": %s %04u", Type, (unsigned) MessageCode);
512 } else {
513 sprintf (Line2, ": %s", Type);
514 }
515 strcat (Line, Line2);
516 fprintf (stdout, "%s", Line);
517 //
518 // If offending text was provided, then print it
519 //
520 if (Text != NULL) {
521 fprintf (stdout, ": %s", Text);
522 }
523 fprintf (stdout, "\n");
524
525 //
526 // Print formatted message if provided
527 //
528 if (MsgFmt != NULL) {
529 vsprintf (Line2, MsgFmt, List);
530 fprintf (stdout, " %s\n", Line2);
531 }
532
533 }
534
535 STATIC
536 VOID
537 PrintSimpleMessage (
538 CHAR8 *MsgFmt,
539 va_list List
540 )
541 /*++
542 Routine Description:
543 Print message into stdout.
544
545 Arguments:
546 MsgFmt - the format string for the message. Can contain formatting
547 controls for use with varargs.
548 List - the variable list.
549
550 Returns:
551 None.
552 --*/
553 {
554 CHAR8 Line[MAX_LINE_LEN];
555 //
556 // Print formatted message if provided
557 //
558 if (MsgFmt != NULL) {
559 vsprintf (Line, MsgFmt, List);
560 fprintf (stdout, "%s\n", Line);
561 }
562 }
563
564 VOID
565 ParserSetPosition (
566 CHAR8 *SourceFileName,
567 UINT32 LineNum
568 )
569 /*++
570
571 Routine Description:
572 Set the position in a file being parsed. This can be used to
573 print error messages deeper down in a parser.
574
575 Arguments:
576 SourceFileName - name of the source file being parsed
577 LineNum - line number of the source file being parsed
578
579 Returns:
580 NA
581
582 --*/
583 {
584 mSourceFileName = SourceFileName;
585 mSourceFileLineNum = LineNum;
586 }
587
588 VOID
589 SetUtilityName (
590 CHAR8 *UtilityName
591 )
592 /*++
593
594 Routine Description:
595 All printed error/warning/debug messages follow the same format, and
596 typically will print a filename or utility name followed by the error
597 text. However if a filename is not passed to the print routines, then
598 they'll print the utility name if you call this function early in your
599 app to set the utility name.
600
601 Arguments:
602 UtilityName - name of the utility, which will be printed with all
603 error/warning/debug messags.
604
605 Returns:
606 NA
607
608 --*/
609 {
610 //
611 // Save the name of the utility in our local variable. Make sure its
612 // length does not exceed our buffer.
613 //
614 if (UtilityName != NULL) {
615 if (strlen (UtilityName) >= sizeof (mUtilityName)) {
616 Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");
617 strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);
618 mUtilityName[sizeof (mUtilityName) - 1] = 0;
619 return ;
620 } else {
621 strcpy (mUtilityName, UtilityName);
622 }
623 } else {
624 Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");
625 }
626 }
627
628 STATUS
629 GetUtilityStatus (
630 VOID
631 )
632 /*++
633
634 Routine Description:
635 When you call Error() or Warning(), this module keeps track of it and
636 sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility
637 exits, it can call this function to get the status and use it as a return
638 value.
639
640 Arguments:
641 None.
642
643 Returns:
644 Worst-case status reported, as defined by which print function was called.
645
646 --*/
647 {
648 return mStatus;
649 }
650
651 VOID
652 SetPrintLevel (
653 UINT64 LogLevel
654 )
655 /*++
656
657 Routine Description:
658 Set the printing message Level. This is used by the PrintMsg() function
659 to determine when/if a message should be printed.
660
661 Arguments:
662 LogLevel - 0~50 to specify the different level message.
663
664 Returns:
665 NA
666
667 --*/
668 {
669 mPrintLogLevel = LogLevel;
670 }
671
672 VOID
673 VerboseMsg (
674 CHAR8 *MsgFmt,
675 ...
676 )
677 /*++
678
679 Routine Description:
680 Print a verbose level message.
681
682 Arguments:
683 MsgFmt - the format string for the message. Can contain formatting
684 controls for use with varargs.
685 List - the variable list.
686
687 Returns:
688 NA
689
690 --*/
691 {
692 va_list List;
693 //
694 // If the debug level is less than current print level, then do nothing.
695 //
696 if (VERBOSE_LOG_LEVEL < mPrintLogLevel) {
697 return ;
698 }
699
700 va_start (List, MsgFmt);
701 PrintSimpleMessage (MsgFmt, List);
702 va_end (List);
703 }
704
705 VOID
706 NormalMsg (
707 CHAR8 *MsgFmt,
708 ...
709 )
710 /*++
711
712 Routine Description:
713 Print a default level message.
714
715 Arguments:
716 MsgFmt - the format string for the message. Can contain formatting
717 controls for use with varargs.
718 List - the variable list.
719
720 Returns:
721 NA
722
723 --*/
724 {
725 va_list List;
726 //
727 // If the debug level is less than current print level, then do nothing.
728 //
729 if (INFO_LOG_LEVEL < mPrintLogLevel) {
730 return ;
731 }
732
733 va_start (List, MsgFmt);
734 PrintSimpleMessage (MsgFmt, List);
735 va_end (List);
736 }
737
738 VOID
739 KeyMsg (
740 CHAR8 *MsgFmt,
741 ...
742 )
743 /*++
744
745 Routine Description:
746 Print a key level message.
747
748 Arguments:
749 MsgFmt - the format string for the message. Can contain formatting
750 controls for use with varargs.
751 List - the variable list.
752
753 Returns:
754 NA
755
756 --*/
757 {
758 va_list List;
759 //
760 // If the debug level is less than current print level, then do nothing.
761 //
762 if (KEY_LOG_LEVEL < mPrintLogLevel) {
763 return ;
764 }
765
766 va_start (List, MsgFmt);
767 PrintSimpleMessage (MsgFmt, List);
768 va_end (List);
769 }
770
771 VOID
772 SetPrintLimits (
773 UINT32 MaxErrors,
774 UINT32 MaxWarnings,
775 UINT32 MaxWarningsPlusErrors
776 )
777 /*++
778
779 Routine Description:
780 Set the limits of how many errors, warnings, and errors+warnings
781 we will print.
782
783 Arguments:
784 MaxErrors - maximum number of error messages to print
785 MaxWarnings - maximum number of warning messages to print
786 MaxWarningsPlusErrors
787 - maximum number of errors+warnings to print
788
789 Returns:
790 NA
791
792 --*/
793 {
794 mMaxErrors = MaxErrors;
795 mMaxWarnings = MaxWarnings;
796 mMaxWarningsPlusErrors = MaxWarningsPlusErrors;
797 mPrintLimitsSet = 1;
798 }
799
800 STATIC
801 VOID
802 PrintLimitExceeded (
803 VOID
804 )
805 {
806 STATIC INT8 mPrintLimitExceeded = 0;
807 //
808 // If we've already printed the message, do nothing. Otherwise
809 // temporarily increase our print limits so we can pass one
810 // more message through.
811 //
812 if (mPrintLimitExceeded == 0) {
813 mPrintLimitExceeded++;
814 mMaxErrors++;
815 mMaxWarnings++;
816 mMaxWarningsPlusErrors++;
817 Error (NULL, 0, 0, "error/warning print limit exceeded", NULL);
818 mMaxErrors--;
819 mMaxWarnings--;
820 mMaxWarningsPlusErrors--;
821 }
822 }
823
824 #if 0
825 VOID
826 TestUtilityMessages (
827 VOID
828 )
829 {
830 CHAR8 *ArgStr = "ArgString";
831 int ArgInt;
832
833 ArgInt = 0x12345678;
834 //
835 // Test without setting utility name
836 //
837 fprintf (stdout, "* Testing without setting utility name\n");
838 fprintf (stdout, "** Test debug message not printed\n");
839 DebugMsg (NULL, 0, 0x00000001, NULL, NULL);
840 fprintf (stdout, "** Test warning with two strings and two args\n");
841 Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
842 fprintf (stdout, "** Test error with two strings and two args\n");
843 Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
844 fprintf (stdout, "** Test parser warning with nothing\n");
845 ParserWarning (0, NULL, NULL);
846 fprintf (stdout, "** Test parser error with nothing\n");
847 ParserError (0, NULL, NULL);
848 //
849 // Test with utility name set now
850 //
851 fprintf (stdout, "** Testingin with utility name set\n");
852 SetUtilityName ("MyUtilityName");
853 //
854 // Test debug prints
855 //
856 SetDebugMsgMask (2);
857 fprintf (stdout, "** Test debug message with one string\n");
858 DebugMsg (NULL, 0, 0x00000002, "Text1", NULL);
859 fprintf (stdout, "** Test debug message with one string\n");
860 DebugMsg (NULL, 0, 0x00000002, NULL, "Text2");
861 fprintf (stdout, "** Test debug message with two strings\n");
862 DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2");
863 fprintf (stdout, "** Test debug message with two strings and two args\n");
864 DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
865 //
866 // Test warning prints
867 //
868 fprintf (stdout, "** Test warning with no strings\n");
869 Warning (NULL, 0, 1234, NULL, NULL);
870 fprintf (stdout, "** Test warning with one string\n");
871 Warning (NULL, 0, 1234, "Text1", NULL);
872 fprintf (stdout, "** Test warning with one string\n");
873 Warning (NULL, 0, 1234, NULL, "Text2");
874 fprintf (stdout, "** Test warning with two strings and two args\n");
875 Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
876 //
877 // Test error prints
878 //
879 fprintf (stdout, "** Test error with no strings\n");
880 Error (NULL, 0, 1234, NULL, NULL);
881 fprintf (stdout, "** Test error with one string\n");
882 Error (NULL, 0, 1234, "Text1", NULL);
883 fprintf (stdout, "** Test error with one string\n");
884 Error (NULL, 0, 1234, NULL, "Text2");
885 fprintf (stdout, "** Test error with two strings and two args\n");
886 Error (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
887 //
888 // Test parser prints
889 //
890 fprintf (stdout, "** Test parser errors\n");
891 ParserSetPosition (__FILE__, __LINE__ + 1);
892 ParserError (1234, NULL, NULL);
893 ParserSetPosition (__FILE__, __LINE__ + 1);
894 ParserError (1234, "Text1", NULL);
895 ParserSetPosition (__FILE__, __LINE__ + 1);
896 ParserError (1234, NULL, "Text2");
897 ParserSetPosition (__FILE__, __LINE__ + 1);
898 ParserError (1234, "Text1", "Text2");
899 ParserSetPosition (__FILE__, __LINE__ + 1);
900 ParserError (1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
901
902 fprintf (stdout, "** Test parser warnings\n");
903 ParserSetPosition (__FILE__, __LINE__ + 1);
904 ParserWarning (4321, NULL, NULL);
905 ParserSetPosition (__FILE__, __LINE__ + 1);
906 ParserWarning (4321, "Text1", NULL);
907 ParserSetPosition (__FILE__, __LINE__ + 1);
908 ParserWarning (4321, NULL, "Text2");
909 ParserSetPosition (__FILE__, __LINE__ + 1);
910 ParserWarning (4321, "Text1", "Text2");
911 ParserSetPosition (__FILE__, __LINE__ + 1);
912 ParserWarning (4321, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
913 }
914 #endif