Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.2 KiB

  1. /************************************************************************/
  2. /* */
  3. /* RCPP - Resource Compiler Pre-Processor for NT system */
  4. /* */
  5. /* ERROR.C - Error Handler Routines */
  6. /* */
  7. /* 04-Dec-90 w-BrianM Update for NT from PM SDK RCPP */
  8. /* */
  9. /************************************************************************/
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include "rcpptype.h"
  14. #include "rcppdecl.h"
  15. #include "rcppext.h"
  16. #include "msgs.h"
  17. /* defines for message types */
  18. #define W_MSG 4000
  19. #define E_MSG 2000
  20. #define F_MSG 1000
  21. static char Errbuff[128] = {
  22. 0};
  23. /************************************************************************/
  24. /* Local Function Prototypes */
  25. /************************************************************************/
  26. void message (int, int, char *);
  27. /************************************************************************/
  28. /* ERROR - Print an error message to STDOUT. */
  29. /************************************************************************/
  30. #define MAX_ERRORS 100
  31. void error (int msgnum)
  32. {
  33. message(E_MSG, msgnum, Msg_Text);
  34. if (++Nerrors > MAX_ERRORS) {
  35. Msg_Temp = GET_MSG (1003);
  36. SET_MSG (Msg_Text, Msg_Temp, MAX_ERRORS);
  37. fatal(1003); /* die - too many errors */
  38. }
  39. return;
  40. }
  41. /************************************************************************/
  42. /* FATAL - Print an error message to STDOUT and exit. */
  43. /************************************************************************/
  44. void fatal (int msgnum)
  45. {
  46. message(F_MSG, msgnum, Msg_Text);
  47. exit(++Nerrors);
  48. }
  49. /************************************************************************/
  50. /* WARNING - Print an error message to STDOUT. */
  51. /************************************************************************/
  52. void warning (int msgnum)
  53. {
  54. message(W_MSG, msgnum, Msg_Text);
  55. }
  56. /************************************************************************/
  57. /* MESSAGE - format and print the message to STDERR. */
  58. /* The msg goes out in the form : */
  59. /* <file>(<line>) : <msgtype> <errnum> <expanded msg> */
  60. /************************************************************************/
  61. void message(int msgtype, int msgnum, char *msg)
  62. {
  63. char mbuff[512];
  64. register char *p = mbuff;
  65. register char *msgname;
  66. char msgnumstr[32];
  67. if (Linenumber > 0 && Filename) {
  68. SET_MSG (p, "%s(%d) : ", Filename, Linenumber);
  69. p += strlen(p);
  70. }
  71. if (msgtype) {
  72. switch (msgtype)
  73. {
  74. case W_MSG:
  75. msgname = GET_MSG(MSG_WARN);
  76. break;
  77. case E_MSG:
  78. msgname = GET_MSG(MSG_ERROR);
  79. break;
  80. case F_MSG:
  81. msgname = GET_MSG(MSG_FATAL);
  82. break;
  83. }
  84. strcpy(p, msgname);
  85. p += strlen(msgname);
  86. SET_MSG(msgnumstr, " %s%d: ", "RC", msgnum);
  87. strcpy(p, msgnumstr);
  88. p += strlen(msgnumstr);
  89. strcpy(p, msg);
  90. p += strlen(p);
  91. }
  92. fwrite(mbuff, strlen(mbuff), 1, stderr);
  93. fwrite("\n", 1, 1, stderr);
  94. if (Srclist && Errfl) {
  95. /* emit messages to error il file too */
  96. fwrite(mbuff, strlen(mbuff), 1, Errfl);
  97. fwrite("\n", 1, 1, Errfl);
  98. }
  99. return;
  100. }