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.

163 lines
6.1 KiB

  1. /************************************************************************/
  2. /* */
  3. /* RCPP - Resource Compiler Pre-Processor for NT system */
  4. /* */
  5. /* MAIN.C - Main Program */
  6. /* */
  7. /* 27-Nov-90 w-BrianM Update for NT from PM SDK RCPP */
  8. /* */
  9. /************************************************************************/
  10. #include "rc.h"
  11. /************************************************************************/
  12. /* Global Varialbes */
  13. /************************************************************************/
  14. WCHAR *Unknown = NULL; /* holder for bad flags */
  15. int Argc;
  16. WCHAR **Argv;
  17. /************************************************************************/
  18. /* Local Function Prototypes */
  19. /************************************************************************/
  20. WCHAR *nextword(void);
  21. void to_human(void);
  22. struct subtab Ztab[] = {
  23. L'a', UNFLAG, &Extension,
  24. L'e', FLAG, &Extension,
  25. L'E', FLAG, &Ehxtension,
  26. L'i', FLAG, &Symbolic_debug,
  27. L'g', FLAG, &Out_funcdef,
  28. L'p', FLAG, &Cmd_pack_size,
  29. L'I', FLAG, &Inteltypes,
  30. L'c', FLAG, &ZcFlag,
  31. 0, 0, 0,
  32. };
  33. struct cmdtab cmdtab[] = {
  34. L"-pc#", (char *)&Path_chars, 1, STRING,
  35. L"-pf", (char *)&NoPasFor, 1, FLAG,
  36. L"-C", (char *)&Cflag, 1, FLAG,
  37. L"-CP#", (char *)&uiCodePage, 1, NUMBER,
  38. L"-D#", (char *)&Defs, 1, PSHSTR,
  39. L"-U#", (char *)&UnDefs, 1, PSHSTR,
  40. L"-E", (char *)&Eflag, 1, FLAG,
  41. L"-I#", (char *)&Includes, 1, PSHSTR,
  42. L"-P", (char *)&Pflag, 1, FLAG,
  43. L"-f", (char *)&Input_file, 1, STRING,
  44. L"-g", (char *)&Output_file, 1, STRING,
  45. L"-J", (char *)&Jflag, 1, FLAG,
  46. L"-Zp", (char *)&Cmd_pack_size, 1, FLAG,
  47. L"-Zp#", (char *)&Cmd_pack_size, 1, NUMBER,
  48. L"-Z*", (char *)Ztab, 1, SUBSTR,
  49. L"-Oi", (char *)&Cmd_intrinsic, 1, FLAG,
  50. L"-Ol", (char *)&Cmd_loop_opt, 1, FLAG,
  51. L"-db#", (char *)&Debug, 1, STRING,
  52. L"-il#", (char *)&Basename, 1, STRING,
  53. L"-xc", (char *)&Cross_compile, 1, FLAG,
  54. L"-H", (char *)&HugeModel, 1, FLAG,
  55. L"-V#", (char *)&Version, 1, STRING,
  56. L"-Gs", (char *)&Cmd_stack_check, 1, UNFLAG,
  57. L"-Gc", (char *)&Plm, 1, FLAG,
  58. L"-char#", (char *)&Char_align, 1, NUMBER,
  59. L"-A#", (char *)&A_string, 1, STRING,
  60. L"-Q#", (char *)&Q_string, 1, STRING,
  61. L"-Fs", (char *)&Srclist, 1, FLAG,
  62. L"-R", (char *)&Rflag, 1, FLAG,
  63. L"*", (char *)&Unknown, 0, STRING,
  64. 0, 0, 0, 0,
  65. };
  66. /************************************************************************/
  67. /* nextword - */
  68. /************************************************************************/
  69. WCHAR *nextword(void)
  70. {
  71. return((--Argc > 0) ? (*++Argv) : 0);
  72. }
  73. /************************************************************************/
  74. /* main - */
  75. /************************************************************************/
  76. int __cdecl
  77. rcpp_main(
  78. int argc,
  79. PWCHAR*argv
  80. )
  81. {
  82. Argc = argc;
  83. Argv = argv;
  84. if(Argv == NULL) {
  85. strcpy (Msg_Text, GET_MSG (1002));
  86. fatal(1007); /* no memory */
  87. }
  88. while(crack_cmd(cmdtab, nextword(), nextword, 0)) ;
  89. if(Unknown) {
  90. Msg_Temp = GET_MSG (1007);
  91. SET_MSG (Msg_Text, sizeof(Msg_Text), Msg_Temp, Unknown, "c1");
  92. fatal(1007); /* unknown flag */
  93. }
  94. if( ! Input_file) {
  95. strcpy (Msg_Text, GET_MSG (1008));
  96. fatal(1008); /* no input file specified */
  97. }
  98. if( ! Output_file) {
  99. strcpy (Msg_Text, GET_MSG (1010));
  100. fatal(1010); /* no output file specified */
  101. }
  102. Prep = TRUE;
  103. if( !Eflag && !Pflag ) {
  104. Eflag = TRUE;
  105. }
  106. wcsncpy(Filename,Input_file,128);
  107. p0_init(Input_file, Output_file, &Defs, &UnDefs);
  108. to_human();
  109. if( Prep_ifstack >= 0 ) {
  110. strcpy (Msg_Text, GET_MSG (1022));
  111. fatal(1022); /* expected #endif */
  112. }
  113. p0_terminate();
  114. return Nerrors;
  115. }
  116. /************************************************************************/
  117. /* to_human : outputs preprocessed text in human readable form. */
  118. /************************************************************************/
  119. void
  120. to_human(
  121. void
  122. )
  123. {
  124. PWCHAR value;
  125. for(;;) {
  126. switch(yylex()) {
  127. case 0:
  128. return;
  129. case L_NOTOKEN:
  130. break;
  131. default:
  132. if (Basic_token == 0) {
  133. strcpy (Msg_Text, GET_MSG (1011));
  134. fatal(1011);
  135. }
  136. value = Tokstrings[Basic_token - L_NOTOKEN].k_text;
  137. myfwrite(value, wcslen(value) * sizeof(WCHAR), 1, OUTPUTFILE);
  138. break;
  139. }
  140. }
  141. }