Source code of Windows XP (NT5)
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.

135 lines
2.6 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* RCDLL.C - */
  4. /* */
  5. /* Windows 3.5 Resource Compiler - Main Module */
  6. /* */
  7. /* */
  8. /****************************************************************************/
  9. #include "rc.h"
  10. #include <setjmp.h>
  11. /* Module handle */
  12. HINSTANCE hInstance;
  13. HWND hWndCaller;
  14. RC_MESSAGE_CALLBACK lpfnMessageCallback;
  15. RC_PARSE_CALLBACK lpfnParseCallback;
  16. /* Function prototypes */
  17. int __cdecl rc_main(int, char**);
  18. int __cdecl rcpp_main(int argc, PWCHAR*argv);
  19. #ifdef __cplusplus
  20. extern "C"
  21. #endif
  22. BOOL
  23. WINAPI
  24. DllMain(
  25. HINSTANCE hDll,
  26. DWORD dwReason,
  27. LPVOID lpReserved
  28. )
  29. {
  30. if (dwReason == DLL_PROCESS_ATTACH) {
  31. hInstance = hDll;
  32. DisableThreadLibraryCalls(hDll);
  33. }
  34. return TRUE;
  35. }
  36. #ifdef __cplusplus
  37. extern "C"
  38. #endif
  39. int CALLBACK
  40. RC(
  41. HWND hWnd,
  42. int fStatus,
  43. RC_MESSAGE_CALLBACK lpfnMsg,
  44. RC_PARSE_CALLBACK lpfnParse,
  45. int argc,
  46. char**argv
  47. )
  48. {
  49. hWndCaller = hWnd;
  50. lpfnMessageCallback = lpfnMsg;
  51. lpfnParseCallback = lpfnParse;
  52. return (rc_main(argc, argv));
  53. }
  54. int
  55. RCPP(
  56. int argc,
  57. PCHAR *argv,
  58. PCHAR env
  59. )
  60. {
  61. WCHAR **wargv;
  62. wargv = UnicodeCommandLine(argc, argv);
  63. return rcpp_main(argc, wargv);
  64. }
  65. void
  66. SendWarning(
  67. PSTR str
  68. )
  69. {
  70. if (lpfnMessageCallback)
  71. (*lpfnMessageCallback)(0, 0, str);
  72. if (hWndCaller) {
  73. if (SendMessageA(hWndCaller, WM_RC_ERROR, FALSE, (LPARAM)str) != 0) {
  74. quit("\n");
  75. }
  76. }
  77. }
  78. void
  79. SendError(
  80. PSTR str
  81. )
  82. {
  83. static int cErrThisLine = 0;
  84. static int LastRow = 0;
  85. if (lpfnMessageCallback)
  86. (*lpfnMessageCallback)(0, 0, str);
  87. if (hWndCaller) {
  88. if (SendMessageA(hWndCaller, WM_RC_ERROR, FALSE, (LPARAM)str) != 0) {
  89. quit("\n");
  90. }
  91. }
  92. if (token.row == LastRow) {
  93. if (++cErrThisLine > 4 && strcmp(str, "\n"))
  94. quit("\n");
  95. } else {
  96. LastRow = token.row;
  97. cErrThisLine = 0;
  98. }
  99. }
  100. void
  101. UpdateStatus(
  102. unsigned nCode,
  103. unsigned long dwStatus
  104. )
  105. {
  106. if (hWndCaller) {
  107. if (SendMessageA(hWndCaller, WM_RC_STATUS, nCode, dwStatus) != 0) {
  108. quit("\n");
  109. }
  110. }
  111. }