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.

159 lines
5.6 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. /************************************************************************/
  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. const 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. wchar_t *argv[]
  80. )
  81. {
  82. Argc = argc;
  83. Argv = argv;
  84. if(Argv == NULL) {
  85. fatal(1002); /* no memory */
  86. }
  87. while(crack_cmd(cmdtab, nextword(), nextword, 0)) ;
  88. if(Unknown) {
  89. fatal(1007, Unknown, L"c1"); /* unknown flag */
  90. }
  91. if( ! Input_file) {
  92. fatal(1008); /* no input file specified */
  93. }
  94. if( ! Output_file) {
  95. fatal(1010); /* no output file specified */
  96. }
  97. Prep = TRUE;
  98. if( !Eflag && !Pflag ) {
  99. Eflag = TRUE;
  100. }
  101. wcsncpy(Filename,Input_file,128);
  102. p0_init(Input_file, Output_file, &Defs, &UnDefs);
  103. to_human();
  104. if( Prep_ifstack >= 0 ) {
  105. fatal(1022); /* expected #endif */
  106. }
  107. p0_terminate();
  108. return Nerrors;
  109. }
  110. /************************************************************************/
  111. /* to_human : outputs preprocessed text in human readable form. */
  112. /************************************************************************/
  113. void
  114. to_human(
  115. void
  116. )
  117. {
  118. const wchar_t *value;
  119. for(;;) {
  120. switch(yylex()) {
  121. case 0:
  122. return;
  123. case L_NOTOKEN:
  124. break;
  125. default:
  126. if (Basic_token == 0) {
  127. fatal(1011);
  128. }
  129. value = Tokstrings[Basic_token - L_NOTOKEN].k_text;
  130. myfwrite(value, wcslen(value) * sizeof(WCHAR), 1, OUTPUTFILE);
  131. break;
  132. }
  133. }
  134. }