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