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.

172 lines
4.4 KiB

  1. /*****************************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1999 **/
  4. /*****************************************************************************/
  5. /*****************************************************************************
  6. File : pass2.cxx
  7. Title : pass2 controller
  8. History :
  9. 24-Aug-1991 VibhasC Created
  10. *****************************************************************************/
  11. #if 0
  12. Notes
  13. -----
  14. This file provides the interface for the acf semantics pass. It also
  15. initializes the pass2 controller object.
  16. #endif // 0
  17. #pragma warning ( disable : 4514 )
  18. /****************************************************************************
  19. includes
  20. ****************************************************************************/
  21. #include "nulldefs.h"
  22. extern "C" {
  23. #include <string.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <malloc.h>
  27. extern int yyacfparse();
  28. }
  29. #include "allnodes.hxx"
  30. #include "control.hxx"
  31. #include "cmdana.hxx"
  32. #include "filehndl.hxx"
  33. #include "idict.hxx"
  34. /****************************************************************************
  35. local definitions
  36. ****************************************************************************/
  37. #define ACF_ATTR_COUNT (ACF_ATTR_END - ACF_ATTR_START)
  38. #define ACF_ATTR_MAX (ACF_ATTR_COUNT - 1)
  39. /****************************************************************************
  40. extern procedures
  41. ****************************************************************************/
  42. extern void initlex();
  43. extern void ParseError( STATUS_T, char * );
  44. /****************************************************************************
  45. extern data
  46. ****************************************************************************/
  47. extern class ccontrol * pCompiler;
  48. extern node_source * pSourceNode;
  49. extern NFA_INFO * pImportCntrl;
  50. extern CMD_ARG * pCommand;
  51. /****************************************************************************
  52. local data
  53. ****************************************************************************/
  54. /****************************************************************************/
  55. _pass2::_pass2()
  56. {
  57. pCompiler->SetPassNumber( ACF_PASS );
  58. }
  59. STATUS_T
  60. _pass2::Go()
  61. {
  62. MEM_ITER MemIter( pSourceNode );
  63. node_file * pFNode;
  64. node_file * pBaseFileNode = 0;
  65. char Buffer[_MAX_DRIVE+_MAX_PATH+_MAX_FNAME+_MAX_EXT+1];
  66. STATUS_T Status = STATUS_OK;
  67. /**
  68. ** create a new import controller for the acf and
  69. ** set the defaults needed
  70. **/
  71. pImportCntrl = pCompiler->SetImportController( new NFA_INFO );
  72. pImportCntrl->Init();
  73. /**
  74. ** for each idl file, check if the corresponding acf exists.
  75. ** if yes, process it.
  76. **/
  77. while ( ( pFNode = (node_file *) MemIter.GetNext() ) != 0 )
  78. {
  79. pFileNode = pFNode;
  80. if(pFNode->GetImportLevel() == 0)
  81. pBaseFileNode = pFNode;
  82. if( pFNode->AcfExists() )
  83. {
  84. pFNode->AcfName( Buffer );
  85. if( !pImportCntrl->IsDuplicateInput( Buffer ) )
  86. {
  87. Status = pImportCntrl->SetNewInputFile( Buffer );
  88. char * pCopy = new char[ strlen( Buffer) + 1];
  89. strcpy( pCopy, Buffer );
  90. AddFileToDB( pCopy );
  91. if( Status != STATUS_OK)
  92. break;
  93. pImportCntrl->ResetEOIFlag();
  94. initlex();
  95. if( yyacfparse() || pCompiler->GetErrorCount() )
  96. {
  97. Status = SYNTAX_ERROR;
  98. break;
  99. }
  100. }
  101. }
  102. else if(pFNode->GetImportLevel() == 0)
  103. {
  104. // he could not find the acf file. If the user did specify
  105. // an acf switch then we must error out if we do not find
  106. // the acf.
  107. if( pCommand->IsSwitchDefined( SWITCH_ACF ) )
  108. {
  109. RpcError((char *)NULL,
  110. 0,
  111. (Status = INPUT_OPEN) ,
  112. pCommand->GetAcfFileName());
  113. break;
  114. }
  115. }
  116. // clean up
  117. pImportCntrl->EndOperations();
  118. } // end of outer while loop
  119. if( (Status == STATUS_OK) )
  120. {
  121. /**
  122. ** The acf pass may have created include file nodes They must translate
  123. ** into include statements in the generated stubs. We handle that by
  124. ** merging the include file list with the members of the source node.
  125. **/
  126. pSourceNode->MergeMembersToHead( AcfIncludeList );
  127. }
  128. else
  129. {
  130. ParseError( ERRORS_PASS1_NO_PASS2, (char *)0 );
  131. }
  132. delete pImportCntrl;
  133. return Status;
  134. }