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