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.

113 lines
2.1 KiB

  1. /***********************************************************************
  2. * Microsoft (R) Windows (R) Resource Compiler
  3. *
  4. * Copyright (c) Microsoft Corporation. All rights reserved.
  5. *
  6. * File Comments:
  7. *
  8. *
  9. ***********************************************************************/
  10. #include "rc.h"
  11. #include "rcmsgs.h"
  12. #define MAX_ERRORS 100
  13. /* defines for message types */
  14. #define W_MSG 4000
  15. #define E_MSG 2000
  16. #define F_MSG 1000
  17. void message(int msgtype, int msgnum, va_list arg_list)
  18. {
  19. SET_MSGV(msgnum, arg_list);
  20. static wchar_t mbuff[512];
  21. wchar_t *p = mbuff;
  22. wchar_t *pT;
  23. const wchar_t *msgname;
  24. wchar_t msgnumstr[32];
  25. if (Linenumber > 0 && Filename) {
  26. swprintf(p, L"%s(%u) : ", Filename, Linenumber);
  27. p += wcslen(p);
  28. #if 0
  29. } else {
  30. wcscpy(p, L"RC : ");
  31. p += wcslen(p);
  32. #endif
  33. }
  34. if (msgtype) {
  35. switch (msgtype) {
  36. case W_MSG:
  37. msgname = L"warning";
  38. break;
  39. case E_MSG:
  40. msgname = L"error";
  41. break;
  42. case F_MSG:
  43. msgname = L"fatal error";
  44. break;
  45. }
  46. wcscpy(p, msgname);
  47. p += wcslen(msgname);
  48. swprintf(msgnumstr, L" RC%04u: ", msgnum);
  49. wcscpy(p, msgnumstr);
  50. p += wcslen(msgnumstr);
  51. wcscpy(p, Msg_Text);
  52. p += wcslen(p);
  53. }
  54. DoMessageCallback(TRUE, mbuff);
  55. }
  56. void fatal(int msgnum, ...)
  57. {
  58. va_list arg_list;
  59. va_start(arg_list, msgnum);
  60. message(F_MSG, msgnum, arg_list);
  61. va_end(arg_list);
  62. quit(NULL);
  63. }
  64. void error(int msgnum, ...)
  65. {
  66. va_list arg_list;
  67. va_start(arg_list, msgnum);
  68. message(E_MSG, msgnum, arg_list);
  69. va_end(arg_list);
  70. if (++Nerrors > MAX_ERRORS) {
  71. fatal(1003, MAX_ERRORS); /* die - too many errors */
  72. }
  73. }
  74. void warning(int msgnum, ...)
  75. {
  76. va_list arg_list;
  77. va_start(arg_list, msgnum);
  78. message(W_MSG, msgnum, arg_list);
  79. va_end(arg_list);
  80. }