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.

366 lines
9.1 KiB

  1. /*****************************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1999 **/
  4. /*****************************************************************************/
  5. /*****************************************************************************
  6. File : miscnode.cxx
  7. Title : miscellaneous typenode handler
  8. History :
  9. 08-Aug-1991 VibhasC Created
  10. *****************************************************************************/
  11. #pragma warning ( disable : 4514 )
  12. /****************************************************************************
  13. includes
  14. ****************************************************************************/
  15. #include "nulldefs.h"
  16. extern "C" {
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. }
  21. #include "allnodes.hxx"
  22. #include "gramutil.hxx"
  23. #include "cmdana.hxx"
  24. #include "control.hxx"
  25. #include "filehndl.hxx"
  26. #include "lextable.hxx"
  27. extern BOOL IsTempName( char * );
  28. /****************************************************************************
  29. extern data
  30. ****************************************************************************/
  31. extern SymTable * pBaseSymTbl;
  32. extern CCONTROL * pCompiler;
  33. extern PASS_1 * pPass1;
  34. extern node_error * pErrorTypeNode;
  35. extern short ImportLevel;
  36. extern CMD_ARG * pCommand;
  37. extern NFA_INFO * pImportCntrl;
  38. extern IINFODICT * pInterfaceInfoDict;
  39. extern LexTable * pMidlLexTable;
  40. /****************************************************************************
  41. local defines
  42. ****************************************************************************/
  43. /****************************************************************************/
  44. /****************************************************************************
  45. node_interface procedures
  46. ****************************************************************************/
  47. node_interface::node_interface( NODE_T Kind )
  48. : named_node( Kind )
  49. {
  50. ProcCount = 0;
  51. CallBackProcCount = 0;
  52. pBaseIntf = NULL;
  53. pDefiningFile = NULL;
  54. OptimFlags = OPTIMIZE_NONE;
  55. OptimLevel = OPT_LEVEL_OS;
  56. fIAmIUnknown = 0;
  57. fPickle = 0;
  58. fHasProcsWithRpcSs = 0;
  59. fSemAnalyzed = 0;
  60. fPrintedDef = 0;
  61. fPrintedIID = 0;
  62. pMyCG = NULL;
  63. pMyTlbCG = NULL;
  64. pProcTbl = NULL;
  65. fHasOLEAutomation = 0;
  66. fIsAsyncClone = 0;
  67. pAsyncInterface = 0;
  68. if ( pCommand->IsSwitchDefined( SWITCH_MS_CONF_STRUCT ) )
  69. {
  70. fHasMSConfStructAttr = TRUE;
  71. }
  72. else
  73. {
  74. fHasMSConfStructAttr = FALSE;
  75. }
  76. }
  77. void
  78. node_interface::GetVersionDetails( unsigned short * Maj,
  79. unsigned short * Min )
  80. {
  81. node_version * pAttr;
  82. pAttr = (node_version *)
  83. GetAttribute( ATTR_VERSION );
  84. if (pAttr)
  85. {
  86. pAttr->GetVersion( Maj, Min );
  87. }
  88. else
  89. {
  90. *Maj = 0;
  91. *Min = 0;
  92. };
  93. };
  94. node_interface *
  95. node_interface::GetMyBaseInterface()
  96. {
  97. node_interface *pRealBaseInterface = 0;
  98. node_interface_reference *pRef;
  99. //Get the real base interface node, skipping over the
  100. //node_forward and the node_interface_reference.
  101. if(pBaseIntf)
  102. {
  103. //if necessary, skip over forward reference node
  104. if(pBaseIntf->NodeKind() == NODE_FORWARD)
  105. pRef = (node_interface_reference *)pBaseIntf->GetChild();
  106. else
  107. pRef = (node_interface_reference *)pBaseIntf;
  108. //skip over the interface reference node.
  109. if(pRef)
  110. pRealBaseInterface = pRef->GetRealInterface();
  111. }
  112. return pRealBaseInterface;
  113. }
  114. /****************************************************************************
  115. node_file procedures
  116. ****************************************************************************/
  117. node_file::node_file(
  118. char * pInputName,
  119. short ImpLevel ) : named_node( NODE_FILE, pInputName )
  120. {
  121. fHasComClasses = FALSE;
  122. /**
  123. ** save our file name and import level
  124. **/
  125. ImportLevel = ImpLevel;
  126. pActualFileName = new char[ strlen( pInputName ) + 1 ];
  127. strcpy( pActualFileName, pInputName );
  128. /**
  129. ** if the pass is the acf pass, then just set the symbol name to
  130. ** be the input name, else munge it.
  131. **/
  132. if( pCompiler->GetPassNumber() == IDL_PASS )
  133. {
  134. fAcfInclude = FALSE;
  135. SetFileName( pInputName );
  136. }
  137. else
  138. {
  139. fAcfInclude = TRUE;
  140. SetSymName( pInputName );
  141. }
  142. fIsXXXBaseIdl = FALSE;
  143. }
  144. void
  145. node_file::SetFileName(
  146. char * pFullName )
  147. {
  148. char pDrive[ _MAX_DRIVE ],
  149. pPath[ _MAX_PATH ],
  150. pName[ _MAX_FNAME ],
  151. pExt[ _MAX_EXT ];
  152. short lenDrive,
  153. lenPath,
  154. lenName,
  155. lenExt;
  156. char * pNewName;
  157. CMD_ARG * pCmd = pCompiler->GetCommandProcessor();
  158. _splitpath( pFullName, pDrive, pPath, pName, pExt );
  159. if( (GetImportLevel() != 0 ) ||
  160. !pCmd->IsSwitchDefined( SWITCH_HEADER ) )
  161. {
  162. strcpy( pExt, ".h" );
  163. }
  164. else
  165. {
  166. pCmd->GetHeaderFileNameComponents( pDrive,pPath,pName,pExt);
  167. }
  168. lenDrive= (short) strlen( pDrive );
  169. lenPath = (short) strlen( pPath );
  170. lenName = (short) strlen( pName );
  171. lenExt = (short) strlen( pExt );
  172. pNewName = new char [ lenDrive + lenPath + lenName + lenExt + 1 ];
  173. strcpy( pNewName, pDrive );
  174. strcat( pNewName, pPath );
  175. strcat( pNewName, pName );
  176. strcat( pNewName, pExt );
  177. SetSymName( pNewName );
  178. // insert the original name into the symbol table to be able to
  179. // access the filename later and get at the aux thru the symbol table
  180. SymKey SKey( pFullName, NAME_FILE );
  181. pBaseSymTbl->SymInsert( SKey, (SymTable *)NULL, (named_node *)this );
  182. }
  183. BOOL
  184. node_file::AcfExists()
  185. {
  186. char agBuf[ _MAX_DRIVE + _MAX_PATH + _MAX_FNAME + _MAX_EXT + 1];
  187. FILE * hFile;
  188. AcfName( agBuf );
  189. if ( agBuf[0] && ( hFile = fopen( agBuf, "r") ) != 0 )
  190. {
  191. fclose( hFile );
  192. return (BOOL)1;
  193. }
  194. return (BOOL)0;
  195. }
  196. void
  197. node_file::AcfName(
  198. char * pBuf )
  199. {
  200. char agDrive[ _MAX_DRIVE ] ,
  201. agPath[ _MAX_PATH ],
  202. agName[ _MAX_FNAME ],
  203. agExt[ _MAX_EXT ];
  204. char agLast[ _MAX_PATH];
  205. char * pPath;
  206. BOOL fUserSpecifiedAcf;
  207. char * pTemp;
  208. // if this is the base idl file, then it can potentially have
  209. // an acf called differently. The imported file will have its acf
  210. // only derived from the idl files name.
  211. fUserSpecifiedAcf = ( ( GetImportLevel() == 0 ) &&
  212. pCommand->IsSwitchDefined( SWITCH_ACF ) );
  213. if( fUserSpecifiedAcf )
  214. pTemp = pCommand->GetAcfFileName();
  215. else
  216. pTemp = pActualFileName;
  217. strcpy( agLast, pTemp );
  218. //
  219. // we need to figure out the complete file name of the file we are searching
  220. // for.
  221. // If the user specified a file
  222. // {
  223. // if it did not have a path component
  224. // then we need to search in the path list that we derive from his
  225. // -I and include env vsriable specification.
  226. // else // (if he did have a path )
  227. // we pick that file up from this path.
  228. // }
  229. // else // (the user did not specify a file )
  230. // {
  231. // we derive the file name from he idl file name and add a .acf to it.
  232. // }
  233. _splitpath( agLast, agDrive, agPath, agName, agExt );
  234. if( fUserSpecifiedAcf )
  235. {
  236. if( (agDrive[0] == '\0') && (agPath[0] == '\0') )
  237. {
  238. // no path was specified,
  239. pPath = (char *)0;
  240. }
  241. else
  242. {
  243. // agLast has the whole thing...
  244. pPath = "";
  245. }
  246. }
  247. else
  248. {
  249. // he did not specify an acf switch, so derive the filename and
  250. // the path. The basename is available, the extension in this case
  251. // is .acf
  252. pPath = (char *)0;
  253. strcpy( agExt, ".acf" );
  254. }
  255. if( ! pPath )
  256. {
  257. strcpy( agLast, agName );
  258. strcat( agLast, agExt );
  259. pPath = pImportCntrl->SearchForFile( agLast );
  260. }
  261. //
  262. // now we know all components of the full file name. Go ahead and
  263. // reconstruct the file name.
  264. //
  265. sprintf(pBuf, "%s%s", pPath, agLast);
  266. //_makepath( pBuf, agDrive, pPath, agName, agExt );
  267. }
  268. /****************************************************************************
  269. node_e_status_t procedures
  270. ****************************************************************************/
  271. node_e_status_t::node_e_status_t() : named_node( NODE_E_STATUS_T, (char *) NULL )
  272. {
  273. node_skl * pC;
  274. char * pName;
  275. GetBaseTypeNode( &pC, SIGN_UNSIGNED, SIZE_LONG, TYPE_INT );
  276. // force name into lexeme table
  277. pName = pMidlLexTable->LexInsert("error_status_t");
  278. SetSymName( pName );
  279. SetChild( pC);
  280. }
  281. /****************************************************************************
  282. node_wchar_t procedures
  283. ****************************************************************************/
  284. node_wchar_t::node_wchar_t() : named_node( NODE_WCHAR_T, (char *) NULL )
  285. {
  286. node_skl * pC;
  287. char * pName;
  288. GetBaseTypeNode( &pC, SIGN_UNSIGNED, SIZE_SHORT, TYPE_INT );
  289. pName = pMidlLexTable->LexInsert("wchar_t");
  290. SetSymName( pName );
  291. SetChild( pC);
  292. }
  293. void
  294. node_forward::GetSymDetails(
  295. NAME_T * pTag,
  296. char ** ppName )
  297. {
  298. *pTag = SKey.GetKind();
  299. *ppName = SKey.GetString();
  300. }