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.

1554 lines
55 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #ifndef __CMDANA_HXX__
  3. #define __CMDANA_HXX__
  4. #include "common.hxx"
  5. #include "errors.hxx"
  6. #include <stream.hxx>
  7. class ISTREAM;
  8. enum _swenum
  9. {
  10. SWITCH_NOTHING
  11. ,BASE_FILENAME = SWITCH_NOTHING
  12. ,SWITCH_D
  13. ,SWITCH_I
  14. ,SWITCH_U
  15. ,SWITCH_W
  16. ,SWITCH_CONFIRM
  17. ,SWITCH_NOLOGO
  18. ,SWITCH_CPP_CMD
  19. ,SWITCH_CPP_OPT
  20. ,SWITCH_MSC_VER
  21. ,SWITCH_CSTUB
  22. ,SWITCH_ENV
  23. ,SWITCH_ERROR
  24. ,SWITCH_ROBUST
  25. ,SWITCH_NO_ROBUST
  26. ,SWITCH_HEADER
  27. ,SWITCH_NO_HEADER
  28. ,SWITCH_NO_CPP
  29. ,SWITCH_NO_DEF_IDIR
  30. ,SWITCH_NO_ENUM_LIT
  31. ,SWITCH_USE_EPV
  32. ,SWITCH_NO_DEFAULT_EPV
  33. ,SWITCH_NO_WARN
  34. ,SWITCH_OUT
  35. ,SWITCH_SSTUB
  36. ,SWITCH_STUB
  37. ,SWITCH_SYNTAX_CHECK
  38. ,SWITCH_TARGET_SYSTEM
  39. ,SWITCH_ZS
  40. ,SWITCH_V
  41. ,SWITCH_VERSION
  42. ,SWITCH_DEBUGEXC
  43. ,SWITCH_DEBUGLINE
  44. ,SWITCH_DEBUG64_OPT
  45. ,SWITCH_DEBUG64
  46. ,SWITCH_APPEND64
  47. ,SWITCH_ACF
  48. ,SWITCH_PACK
  49. ,SWITCH_ZP
  50. ,SWITCH_CLIENT
  51. ,SWITCH_NO_CLIENT
  52. ,SWITCH_SERVER
  53. ,SWITCH_NO_SERVER
  54. ,SWITCH_PREFIX
  55. ,SWITCH_SUFFIX
  56. ,SWITCH_DUMP
  57. ,SWITCH_SAVEPP
  58. ,SWITCH_CHAR
  59. ,SWITCH_HELP
  60. ,SWITCH_WX
  61. ,SWITCH_X
  62. ,SWITCH_MS_EXT
  63. ,SWITCH_MS_CONF_STRUCT
  64. ,SWITCH_APP_CONFIG
  65. ,SWITCH_INTERNAL
  66. ,SWITCH_NO_STAMP
  67. ,SWITCH_C_EXT
  68. ,SWITCH_O
  69. // files for proxies
  70. ,SWITCH_IID
  71. ,SWITCH_NO_IID
  72. ,SWITCH_PROXY
  73. ,SWITCH_NO_PROXY
  74. ,SWITCH_PROXY_DEF
  75. ,SWITCH_NO_PROXY_DEF
  76. ,SWITCH_DLLDATA
  77. ,SWITCH_NO_DLLDATA
  78. // files for inprocserver32s
  79. ,SWITCH_DLL_SERVER_DEF
  80. ,SWITCH_NO_DLL_SERVER_DEF
  81. ,SWITCH_DLL_SERVER_CLASS_GEN
  82. ,SWITCH_NO_DLL_SERVER_CLASS_GEN
  83. // files for localserver32s
  84. ,SWITCH_EXE_SERVER_MAIN
  85. ,SWITCH_NO_EXE_SERVER_MAIN
  86. ,SWITCH_EXE_SERVER
  87. ,SWITCH_NO_EXE_SERVER
  88. // files for both
  89. ,SWITCH_TESTCLIENT
  90. ,SWITCH_NO_TESTCLIENT
  91. ,SWITCH_SERVER_REG
  92. ,SWITCH_NO_SERVER_REG
  93. // files for com class servers
  94. ,SWITCH_CLASS_METHODS
  95. ,SWITCH_NO_CLASS_METHODS
  96. ,SWITCH_CLASS_IUNKNOWN
  97. ,SWITCH_NO_CLASS_IUNKNOWN
  98. ,SWITCH_CLASS_HEADER
  99. ,SWITCH_NO_CLASS_HEADER
  100. ,SWITCH_MS_UNION
  101. ,SWITCH_OVERRIDE
  102. ,SWITCH_GUARD_DEFS
  103. ,SWITCH_OLDNAMES
  104. ,SWITCH_RPCSS
  105. ,SWITCH_NO_FMT_OPT
  106. ,SWITCH_OSF // disables setting /ms_ext and /c_ext as default
  107. ,SWITCH_HOOKOLE
  108. ,SWITCH_NETMON
  109. ,SWITCH_NETMON_STUB_OUTPUT_FILE
  110. ,SWITCH_NETMON_STUB_OBJ_OUTPUT_FILE
  111. ,SWITCH_VERSION_STAMP
  112. // MKTYPLIB switches
  113. ,SWITCH_TLIB
  114. ,SWITCH_TLIB64
  115. ,SWITCH_REDIRECT_OUTPUT
  116. ,SWITCH_ODL_ENV
  117. ,SWITCH_MKTYPLIB
  118. ,SWITCH_OLD_TLB
  119. ,SWITCH_NEW_TLB
  120. ,SWITCH_LOCALE_ID
  121. ,SWITCH_NOREUSE_BUFFER
  122. ,SWITCH_USE_VT_INT_PTR
  123. ,SWITCH_NO_TLIB
  124. ,SWITCH_TRANSFER_SYNTAX
  125. ,SWITCH_MS_EXT64
  126. ,SWITCH_DEBUGINFO
  127. ,SWITCH_WIRE_COMPAT
  128. //
  129. // enter all new switches before this label
  130. //
  131. ,SW_VALUE_MAX
  132. };
  133. /*** client : can take values "stub", "none" ***/
  134. #define CLNT_STUB (0x0)
  135. #define CLNT_NONE (0x2)
  136. /*** server : can take values "stub", "none" ***/
  137. #define SRVR_STUB (0x0)
  138. #define SRVR_NONE (0x2)
  139. /** env switch values **/
  140. #define ENV_WIN32 (0x4)
  141. #define ENV_WIN64 (0x20)
  142. #define ENV_OBSOLETE (0)
  143. /** targeted system switch values **/
  144. typedef enum _target_enum
  145. {
  146. NOTARGET = 0,
  147. NT40 = 40,
  148. NT50 = 50,
  149. NT51 = 51
  150. } TARGET_ENUM;
  151. #define DEFAULT_ZEEPEE (8)
  152. /** error switch values **/
  153. #define ERROR_NONE (0x0000)
  154. #define ERROR_BOUNDS_CHECK (0x0001)
  155. #define ERROR_ENUM (0x0002)
  156. #define ERROR_ALLOCATION (0x0004)
  157. #define ERROR_REF (0x0008)
  158. #define ERROR_STUB_DATA (0x0010)
  159. #define ERROR_ALL (ERROR_BOUNDS_CHECK | \
  160. ERROR_ENUM | \
  161. ERROR_ALLOCATION | \
  162. ERROR_REF | \
  163. ERROR_STUB_DATA \
  164. )
  165. /** char switch values **/
  166. #define CHAR_SIGNED (0x1)
  167. #define CHAR_UNSIGNED (0x2)
  168. #define CHAR_ANSI7 (0x3)
  169. /** rpc ss allocate **/
  170. #define RPC_SS_ALLOCATE_DISABLED (0x0)
  171. #define RPC_SS_ALLOCATE_ENABLED (0x1)
  172. /** manifests defining prefix arguments **/
  173. #define PREFIX_CLIENT_STUB (0x0)
  174. #define PREFIX_SERVER_MGR (0x1)
  175. #define PREFIX_SWICH_PROTOTYPE (0x2)
  176. #define PREFIX_ALL (0x3)
  177. /** wire compatibility options (allocated as bitfields) **/
  178. #define WIRE_COMPAT_ENUM16UNIONALIGN (0x0001)
  179. /*****************************************************************************
  180. * some data structures used.
  181. *****************************************************************************/
  182. // basically a singly linked list implementation,
  183. // used for switches which can be specified multiply like -D / -I etc
  184. typedef struct _optlist
  185. {
  186. char * pStr; // pointer to argument string
  187. struct _optlist * pNext; // pointer to the next argument
  188. size_t ActualOffset;
  189. bool NeedsQuotes;
  190. } OptList;
  191. /*****************************************************************************
  192. * class defintions used by the command analyser.
  193. *****************************************************************************/
  194. //
  195. // the multiple occurence switch class
  196. // This class of switches are ones which can be specified multiple times
  197. // on the command line. Examples of such switches are -D / -U �/ -I etc
  198. // This switch really keeps a linked list of all arguments specified for
  199. // the switch.
  200. //
  201. class multiple_switch
  202. {
  203. private:
  204. OptList * pFirst, // first of the list of arguments.
  205. * pCurrent; // current in the scan of list of args.
  206. public:
  207. // constructor
  208. multiple_switch( ) : pFirst(NULL), pCurrent(NULL) {};
  209. multiple_switch( char *pArg, size_t ActualOffset );
  210. // add the arguments of another occurence of this switch
  211. void Add( char *, size_t ActualOffset );
  212. // initialise the scan of the list. Called before any GetNextIsDone
  213. void Init();
  214. // Get the argument to the next occurence of the switch
  215. char * GetNext( size_t *pActualOffset = NULL, bool *pNeedQuotes = NULL );
  216. // Collect all the arguments into a buffer
  217. char * GetConsolidatedOptions( bool NeedsQuotes = false );
  218. // return the length of all the arguments. Generally used to allocate
  219. // a buffer size for a GetConsolidatedOptions call.
  220. short GetConsolidatedLength( bool NeedsQuotes = false );
  221. void StreamIn( char*& );
  222. void StreamOut( STREAM* );
  223. };
  224. //
  225. // the onetime_switch class.
  226. // such a switch can occur only once, and takes just one argument. We need
  227. // to hold on to the argument during compilation.
  228. //
  229. class onetime_switch
  230. {
  231. char * pOpt; // the user argument
  232. public:
  233. // the constructor.
  234. onetime_switch(
  235. char * pArg = 0 // argument to switch
  236. );
  237. // the destructor
  238. ~onetime_switch();
  239. // get the user option
  240. char * GetOption();
  241. // get length of the user option string
  242. short GetLength();
  243. void StreamIn( char*& pBuffer );
  244. void StreamOut( STREAM* );
  245. };
  246. //
  247. // the filename_switch
  248. //
  249. // There are a lot of switches which have filenames as arguments. This
  250. // class exists to ease processing of such switches, all of whom behave more
  251. // or less the same way. Only the -out switch is a little different.
  252. // We need to access the filename components too, so we store both as
  253. // components and as the full name.
  254. //
  255. class filename_switch
  256. {
  257. private:
  258. char * pFullName;
  259. public:
  260. // the constructor. Takes an argument as the switch it is defining, so that
  261. // it can check for a redef.
  262. filename_switch(
  263. char * pThisArg = 0 // this argument is supplied
  264. );
  265. // the constructor. It takes a set of filename components. This is not
  266. // called as a result of a user switch, but by internal routines which
  267. // do not need to check for duplicate definitions.
  268. filename_switch(
  269. char * pD, // drive
  270. char * pP, // path
  271. char * pN, // base name
  272. char * pE, // extension
  273. char * pS // suffix ("_c/_s") etc to name
  274. // etc.
  275. );
  276. // the destructor
  277. ~filename_switch();
  278. // Set file name components , given a full name.
  279. void SetFileName(
  280. char * pName // full name
  281. );
  282. // set file name and components, given the components. Note that some
  283. // components may be null, indicating that they are absent.
  284. void SetFileName(
  285. char * pD, // drive
  286. char * pP, // path
  287. char * pN, // base name
  288. char * pE, // extension
  289. char * pS // suffix to name
  290. );
  291. // the the full filename
  292. char * GetFileName( void );
  293. // Get the file name components. If an input pointer is NULL, it means the
  294. // user is not interested in that component of the filename.
  295. void GetFileNameComponents(
  296. char * pD, // buffer for drive
  297. char * pP, // buffer for path
  298. char * pN, // buffer for name
  299. char * pE // buffer for ext
  300. );
  301. void TransformFileNameForOut(
  302. char * pD, // drive
  303. char * pP // path
  304. );
  305. void StreamIn( char*& pBuffer );
  306. void StreamOut( STREAM* );
  307. };
  308. // This data structure is used for specifying data for switches which can take
  309. // different user specification, eg -mode ( osf | msft | c_port ) etc.
  310. typedef struct _choice
  311. {
  312. const char * pChoice; // user input
  313. short Choice; // internal compiler code.
  314. } CHOICE;
  315. class CommandLine;
  316. // this data structure is for paired items, like prefix
  317. class pair_switch
  318. {
  319. private:
  320. CHOICE * pArrayOfChoices;
  321. char ** pUserStrings;
  322. long ArraySize;
  323. short Current;
  324. public:
  325. // get the index of a particular system string
  326. short GetIndex( char * pSys );
  327. // constructor
  328. pair_switch( const CHOICE * pValidChoices );
  329. // construction functions
  330. // void CmdProcess( CommandLine*, char *pF);
  331. void AddPair( short index, char * pUser );
  332. // get the user defined equivalent of this system defined prefix string
  333. char * GetUserDefinedEquivalent( short );
  334. // iteration functions ( for printout )
  335. void Init()
  336. {
  337. Current = -1;
  338. }
  339. short GetNext( char ** pSys, char ** pUser );
  340. void StreamIn( char*& );
  341. void StreamOut( STREAM* );
  342. };
  343. /////////////////////////////////////////////////////////////////////////////
  344. //
  345. // Class for Ndr stub version control
  346. // - what compiler guesses from the usage.
  347. //
  348. /////////////////////////////////////////////////////////////////////////////
  349. class NdrVersionControl
  350. {
  351. // NT 3.51 or Win95
  352. // VTable size limit is 32
  353. unsigned long fHasStublessProxies : 1;
  354. unsigned long fHasCommFaultStatusInOi12 : 1;
  355. // NT 4.0 or DCOM Win95
  356. unsigned long fHasOi2 : 1;
  357. unsigned long fHasUserMarshal : 1;
  358. unsigned long fHasRawPipes : 1;
  359. unsigned long fHasFloatOrDoubleInOi : 1;
  360. unsigned long fHasMoreThan64DelegatedProcs : 1;
  361. unsigned long fHasNT4VTableSize : 1; // 110 methods
  362. // NT 4.0 + SP3
  363. unsigned long fHasMessageAttr : 1;
  364. unsigned long fHasNT43VTableSize : 1; // 512 methods
  365. // NT 5.0
  366. // fHasObjectPipes // revoked later.
  367. unsigned long fHasAsyncHandleRpc : 1;
  368. unsigned long fHasNT5VTableSize : 1; // 1024 methods
  369. // NT 5.0 Beta 2
  370. unsigned long fHasDOA : 1;
  371. unsigned long fHasAsyncUUID : 1;
  372. unsigned long fHasInterpretedNotify : 1;
  373. unsigned long fHasContextSerialization : 1;
  374. // Unlimited number of methods
  375. // NT 5.0 Beta 3
  376. unsigned long fHasOicfPickling : 1;
  377. // NT 6.0
  378. unsigned long f64BitSupport : 1;
  379. unsigned long fHasStructPadN : 1;
  380. unsigned long fMultiTransferSyntax : 1;
  381. unsigned long fHasMsExt64 : 1;
  382. unsigned long fHasPartialIgnore : 1;
  383. unsigned long fHasForceAllocate : 1;
  384. unsigned long fInterpretedComplexReturns : 1;
  385. unsigned long Unused : 8;
  386. TARGET_ENUM TargetSystem;
  387. public:
  388. NdrVersionControl()
  389. {
  390. ClearNdrVersionControl();
  391. }
  392. void SetHasStublessProxies()
  393. {
  394. fHasStublessProxies = 1;
  395. }
  396. unsigned long HasStublessProxies()
  397. {
  398. return fHasStublessProxies;
  399. }
  400. void SetHasOi2()
  401. {
  402. fHasOi2 = 1;
  403. }
  404. unsigned long HasOi2()
  405. {
  406. return fHasOi2;
  407. }
  408. void SetHasUserMarshal()
  409. {
  410. fHasUserMarshal = 1;
  411. }
  412. unsigned long HasUserMarshal()
  413. {
  414. return fHasUserMarshal;
  415. }
  416. void SetHasRawPipes()
  417. {
  418. fHasRawPipes = 1;
  419. }
  420. unsigned long HasRawPipes()
  421. {
  422. return fHasRawPipes;
  423. }
  424. void SetHasMessageAttr()
  425. {
  426. fHasMessageAttr = 1;
  427. }
  428. unsigned long HasMessageAttr()
  429. {
  430. return fHasMessageAttr;
  431. }
  432. void SetHasAsyncHandleRpc()
  433. {
  434. fHasAsyncHandleRpc = 1;
  435. }
  436. unsigned long HasAsyncHandleRpc()
  437. {
  438. return fHasAsyncHandleRpc;
  439. }
  440. void SetHasMoreThan64DelegatedProcs()
  441. {
  442. fHasMoreThan64DelegatedProcs = 1;
  443. }
  444. unsigned long HasMoreThan64DelegatedProcs()
  445. {
  446. return fHasMoreThan64DelegatedProcs;
  447. }
  448. void SetHasNT4VTableSize()
  449. {
  450. fHasNT4VTableSize = 1;
  451. }
  452. unsigned long HasNT4VTableSize()
  453. {
  454. return fHasNT4VTableSize;
  455. }
  456. void SetHasNT43VTableSize()
  457. {
  458. fHasNT43VTableSize = 1;
  459. }
  460. unsigned long HasNT43VTableSize()
  461. {
  462. return fHasNT43VTableSize;
  463. }
  464. void SetHasNT5VTableSize()
  465. {
  466. fHasNT5VTableSize = 1;
  467. }
  468. unsigned long HasNT5VTableSize()
  469. {
  470. return fHasNT5VTableSize;
  471. }
  472. void SetHasFloatOrDoubleInOi()
  473. {
  474. fHasFloatOrDoubleInOi = 1;
  475. }
  476. unsigned long HasFloatOrDoubleInOi()
  477. {
  478. return fHasFloatOrDoubleInOi;
  479. }
  480. void SetHasCommFaultStatusInOi12()
  481. {
  482. fHasCommFaultStatusInOi12 = 1;
  483. }
  484. unsigned long HasCommFaultStatusInOi12()
  485. {
  486. return fHasCommFaultStatusInOi12;
  487. }
  488. void SetHasDOA()
  489. {
  490. fHasDOA = 1;
  491. }
  492. unsigned long HasDOA()
  493. {
  494. return fHasDOA;
  495. }
  496. void SetHasAsyncUUID()
  497. {
  498. fHasAsyncUUID = 1;
  499. }
  500. unsigned long HasAsyncUUID()
  501. {
  502. return fHasAsyncUUID;
  503. }
  504. void SetHasInterpretedNotify()
  505. {
  506. fHasInterpretedNotify = 1;
  507. }
  508. unsigned long HasInterpretedNotify()
  509. {
  510. return fHasInterpretedNotify;
  511. }
  512. void SetHasContextSerialization()
  513. {
  514. fHasContextSerialization = 1;
  515. }
  516. unsigned long HasContextSerialization()
  517. {
  518. return fHasContextSerialization;
  519. }
  520. void SetHasOicfPickling()
  521. {
  522. fHasOicfPickling = 1;
  523. }
  524. unsigned long HasOicfPickling()
  525. {
  526. return fHasOicfPickling;
  527. }
  528. void SetHas64BitSupport()
  529. {
  530. f64BitSupport = 1;
  531. }
  532. unsigned long Has64BitSupport()
  533. {
  534. return f64BitSupport;
  535. }
  536. void SetHasStructPadN()
  537. {
  538. fHasStructPadN = 1;
  539. }
  540. unsigned long HasStructPadN()
  541. {
  542. return fHasStructPadN;
  543. }
  544. void SetHasMultiTransferSyntax()
  545. {
  546. fMultiTransferSyntax = 1;
  547. }
  548. unsigned long HasMultiTransferSyntax()
  549. {
  550. return fMultiTransferSyntax;
  551. }
  552. void SetHasMsExt64()
  553. {
  554. fHasMsExt64 = 1;
  555. }
  556. unsigned long HasMsExt64()
  557. {
  558. return fHasMsExt64;
  559. }
  560. void SetHasPartialIgnore()
  561. {
  562. fHasPartialIgnore = 1;
  563. }
  564. unsigned long HasPartialIgnore()
  565. {
  566. return fHasPartialIgnore;
  567. }
  568. void SetHasForceAllocate()
  569. {
  570. fHasForceAllocate = 1;
  571. }
  572. unsigned long HasForceAllocate()
  573. {
  574. return fHasForceAllocate;
  575. }
  576. void ClearNdrVersionControl()
  577. {
  578. fHasStublessProxies = 0;
  579. fHasCommFaultStatusInOi12 = 0;
  580. fHasOi2 = 0;
  581. fHasUserMarshal = 0;
  582. fHasRawPipes = 0;
  583. fHasFloatOrDoubleInOi = 0;
  584. fHasMessageAttr = 0;
  585. fHasMoreThan64DelegatedProcs = 0;
  586. fHasAsyncHandleRpc = 0;
  587. fHasNT4VTableSize = 0;
  588. fHasNT43VTableSize = 0;
  589. fHasNT5VTableSize = 0;
  590. fHasDOA = 0;
  591. fHasAsyncUUID = 0;
  592. fHasInterpretedNotify = 0;
  593. fHasContextSerialization = 0;
  594. fHasOicfPickling = 0;
  595. f64BitSupport = 0;
  596. fHasStructPadN = 0;
  597. fMultiTransferSyntax = 0;
  598. fHasMsExt64 = 0;
  599. fHasForceAllocate = 0;
  600. fHasPartialIgnore = 0;
  601. Unused = 0;
  602. TargetSystem = NOTARGET;
  603. }
  604. void AddtoNdrVersionControl(
  605. NdrVersionControl & VC )
  606. {
  607. fHasStublessProxies |= VC.HasStublessProxies();
  608. fHasCommFaultStatusInOi12 |= VC.HasCommFaultStatusInOi12();
  609. fHasOi2 |= VC.HasOi2();
  610. fHasUserMarshal |= VC.HasUserMarshal();
  611. fHasRawPipes |= VC.HasRawPipes();
  612. fHasMoreThan64DelegatedProcs |= VC.HasMoreThan64DelegatedProcs();
  613. fHasFloatOrDoubleInOi |= VC.HasFloatOrDoubleInOi();
  614. fHasMessageAttr |= VC.HasMessageAttr();
  615. fHasAsyncHandleRpc |= VC.HasAsyncHandleRpc();
  616. fHasNT4VTableSize |= VC.HasNT4VTableSize();
  617. fHasNT43VTableSize |= VC.HasNT43VTableSize();
  618. fHasNT5VTableSize |= VC.HasNT5VTableSize();
  619. fHasDOA |= VC.HasDOA();
  620. fHasAsyncUUID |= VC.HasAsyncUUID();
  621. fHasInterpretedNotify |= VC.HasInterpretedNotify();
  622. fHasContextSerialization |= VC.HasContextSerialization();
  623. fHasOicfPickling |= VC.HasOicfPickling();
  624. f64BitSupport |= VC.Has64BitSupport();
  625. fHasStructPadN |= VC.HasStructPadN();
  626. fMultiTransferSyntax |= VC.HasMultiTransferSyntax();
  627. fHasMsExt64 |= VC.HasMsExt64();
  628. fHasForceAllocate |= VC.HasForceAllocate();
  629. // REVIEW
  630. if (VC.TargetSystem > TargetSystem)
  631. TargetSystem = VC.TargetSystem;
  632. }
  633. BOOL HasNdr11Feature()
  634. {
  635. return ( fHasStublessProxies ||
  636. fHasCommFaultStatusInOi12 );
  637. }
  638. BOOL HasNdr20Feature()
  639. {
  640. return ( fHasOi2 ||
  641. fHasUserMarshal ||
  642. fHasRawPipes ||
  643. fHasMoreThan64DelegatedProcs ||
  644. fHasFloatOrDoubleInOi ||
  645. fHasMessageAttr ||
  646. TargetSystem >= NT40 );
  647. }
  648. BOOL HasNdr50Feature()
  649. {
  650. return ( fHasAsyncHandleRpc ||
  651. fHasDOA ||
  652. fHasAsyncUUID ||
  653. fHasInterpretedNotify ||
  654. fHasContextSerialization ||
  655. fHasOicfPickling ||
  656. f64BitSupport ||
  657. TargetSystem >= NT50 );
  658. }
  659. // Note, "ndr60" is kind of confusing. This is the
  660. // version of ndr that shipped with NT 5.1
  661. // (aka "Whistler").
  662. BOOL HasNdr60Feature()
  663. {
  664. return HasStructPadN() ||
  665. fMultiTransferSyntax ||
  666. fHasForceAllocate ||
  667. fHasPartialIgnore ||
  668. TargetSystem >= NT51;
  669. }
  670. BOOL IsNdr60orLaterRequired()
  671. {
  672. return HasNdr60Feature();
  673. }
  674. BOOL IsNdr50orLaterRequired()
  675. {
  676. return HasNdr50Feature();
  677. }
  678. void SetTargetSystem( TARGET_ENUM target )
  679. {
  680. TargetSystem = target;
  681. }
  682. TARGET_ENUM GetTargetSystem()
  683. {
  684. return TargetSystem;
  685. }
  686. BOOL TargetIsNT40OrLater()
  687. {
  688. return (TargetSystem >= NT40);
  689. }
  690. BOOL TargetIsNT50OrLater()
  691. {
  692. return (TargetSystem >= NT50);
  693. }
  694. BOOL TargetIsLessThanNT50()
  695. {
  696. return ( NOTARGET != TargetSystem )
  697. && ( TargetSystem < NT50 );
  698. }
  699. BOOL TargetIsNT51OrLater()
  700. {
  701. return (TargetSystem >= NT51);
  702. }
  703. BOOL TargetIsLessThanNT51()
  704. {
  705. return ( NOTARGET != TargetSystem )
  706. && ( TargetSystem < NT51 );
  707. }
  708. BOOL AllowIntrepretedComplexReturns()
  709. {
  710. return HasMultiTransferSyntax();
  711. }
  712. };
  713. /////////////////////////////////////////////////////////////////////////////
  714. // the big boy - the command analyser object
  715. /////////////////////////////////////////////////////////////////////////////
  716. typedef class _cmd_arg
  717. {
  718. protected:
  719. unsigned long switch_def_vector[ 5 ]; // switch definition vector
  720. unsigned char fClient; // client switch options
  721. unsigned char fServer; // server switch options
  722. unsigned char Env; // env - flat /segmented
  723. unsigned char CharOption; // char option
  724. unsigned char fMintRun; // this is a mint ( MIDL-lint) run
  725. unsigned short MajorVersion; // major version
  726. unsigned short MinorVersion; // minor version
  727. unsigned short UpdateNumber; // update
  728. unsigned short ErrorOption; // error option
  729. unsigned short WireCompatOption; // wire_compat options
  730. unsigned short ConfigMask; // configuration mask for error reporting
  731. unsigned short MSCVersion; // MS C Compiler version
  732. bool fShowLogo;
  733. NdrVersionControl VersionControl; // compiler evaluation
  734. unsigned short OptimFlags; // optimization flags from user
  735. OPT_LEVEL_ENUM OptimLevel; // internal optimization level
  736. TARGET_ENUM TargetSystem; // targeted system
  737. SYNTAX_ENUM TargetSyntax;
  738. short iArgV; // index into the argument vector
  739. short cArgs; // count of arguments
  740. short WLevel; // warning level
  741. unsigned short ZeePee; // the Zp switch option value
  742. unsigned short EnumSize; // memory size of enum16
  743. unsigned long LocaleId; // the lcid for MBCS
  744. BOOL fDoubleFor64; // double run marker
  745. BOOL fHasAppend64; // the 64 append run
  746. BOOL fIsNDR64Run; // NDR64 run
  747. BOOL fIsNDRRun; // NDR run
  748. BOOL fIs2ndCodegenRun; // protocol all
  749. BOOL fNeedsNDR64Header; // protocol all, no -env, 32bit
  750. char szCompileTime[32];
  751. char szCompilerVersion[32];
  752. filename_switch * pInputFNSwitch, // input file name
  753. * pOutputPathSwitch, // output path
  754. * pCStubSwitch, // cstub
  755. * pSStubSwitch, // sstub
  756. * pHeaderSwitch, // header
  757. * pAcfSwitch, // acf
  758. * pIIDSwitch, // iid
  759. * pDllDataSwitch, // dlldata
  760. * pProxySwitch, // proxy
  761. * pProxyDefSwitch, // proxy
  762. * pTlibSwitch, // Type Library file name
  763. * pNetmonStubSwitch, // Netmon stub file
  764. * pNetmonStubObjSwitch, // Netmon stub file
  765. * pRedirectOutputSwitch; // redirect stdout to this file
  766. pair_switch * pSwitchPrefix; // -prefix
  767. pair_switch * pSwitchSuffix; // -suffix
  768. multiple_switch * pDSwitch, // -D
  769. * pISwitch, // -I
  770. * pUSwitch; // -U
  771. onetime_switch * pCppCmdSwitch, // cpp_cmd
  772. * pCppOptSwitch, // cpp_opt
  773. * pMSCVerSwitch, // msc_ver
  774. * pDebug64Switch, // debug64
  775. * pDebug64OptSwitch; // debug64_opt
  776. public:
  777. _cmd_arg();
  778. // Is the switch defined ?
  779. BOOL IsSwitchDefined( short SWNo )
  780. {
  781. unsigned long sw = switch_def_vector[ SWNo / 32 ];
  782. unsigned long temp = SWNo % 32;
  783. sw = sw & ( (unsigned long)1 << temp );
  784. return sw ? (BOOL)1 : (BOOL)0;
  785. }
  786. // Set the switch to be defined.
  787. void SwitchDefined( short );
  788. // Get filename.
  789. char * GetInputFileName()
  790. {
  791. return pInputFNSwitch->GetFileName();
  792. }
  793. void GetInputFileNameComponents(
  794. char *pD, // drive buffer
  795. char *pP, // path buffer
  796. char *pN, // base name buffer
  797. char *pE // extension buffer
  798. )
  799. {
  800. pInputFNSwitch->GetFileNameComponents( pD,
  801. pP,
  802. pN,
  803. pE );
  804. }
  805. char * GetAcfFileName()
  806. {
  807. return pAcfSwitch->GetFileName();
  808. }
  809. void GetAcfFileNameComponents(
  810. char *pD,
  811. char *pP,
  812. char *pN,
  813. char *pE )
  814. {
  815. pAcfSwitch->GetFileNameComponents( pD,
  816. pP,
  817. pN,
  818. pE );
  819. }
  820. char * GetOutputPath();
  821. char * GetCstubFName()
  822. {
  823. return pCStubSwitch->GetFileName();
  824. }
  825. void GetCstubFileNameComponents(
  826. char *pD,
  827. char *pP,
  828. char *pN,
  829. char *pE )
  830. {
  831. pCStubSwitch->GetFileNameComponents( pD,
  832. pP,
  833. pN,
  834. pE );
  835. }
  836. char * GetSstubFName()
  837. {
  838. return pSStubSwitch->GetFileName();
  839. }
  840. void GetSstubFileNameComponents(
  841. char *pD,
  842. char *pP,
  843. char *pN,
  844. char *pE )
  845. {
  846. pSStubSwitch->GetFileNameComponents( pD,
  847. pP,
  848. pN,
  849. pE );
  850. }
  851. char * GetHeader()
  852. {
  853. return pHeaderSwitch->GetFileName();
  854. }
  855. void GetHeaderFileNameComponents(
  856. char *pD,
  857. char *pP,
  858. char *pN,
  859. char *pE )
  860. {
  861. pHeaderSwitch->GetFileNameComponents( pD,
  862. pP,
  863. pN,
  864. pE );
  865. }
  866. char * GetIIDFName()
  867. {
  868. return pIIDSwitch->GetFileName();
  869. }
  870. char * GetDllDataFName()
  871. {
  872. return pDllDataSwitch->GetFileName();
  873. }
  874. char * GetProxyFName()
  875. {
  876. return pProxySwitch->GetFileName();
  877. }
  878. char * GetTypeLibraryFName()
  879. {
  880. return pTlibSwitch->GetFileName();
  881. }
  882. char * GetNetmonStubFName()
  883. {
  884. return pNetmonStubSwitch->GetFileName();
  885. }
  886. char * GetNetmonStubObjFName()
  887. {
  888. return pNetmonStubObjSwitch->GetFileName();
  889. }
  890. // get preprocessor command
  891. char * GetCPPCmd()
  892. {
  893. return pCppCmdSwitch->GetOption();
  894. }
  895. // get preprocessor options
  896. char * GetCPPOpt()
  897. {
  898. return pCppOptSwitch->GetOption();
  899. }
  900. bool ShowLogo()
  901. {
  902. return fShowLogo;
  903. }
  904. unsigned short GetMSCVer()
  905. {
  906. return MSCVersion;
  907. }
  908. char * GetDebug64()
  909. {
  910. return pDebug64Switch->GetOption();
  911. }
  912. char * GetDebug64Opt()
  913. {
  914. return pDebug64OptSwitch->GetOption();
  915. }
  916. // get warning level
  917. short GetWarningLevel() { return WLevel; };
  918. // get env switch value
  919. short GetEnv()
  920. {
  921. return (short)Env;
  922. }
  923. void SetEnv( int env )
  924. {
  925. Env = (unsigned char) env;
  926. }
  927. TARGET_ENUM GetTargetSystem()
  928. {
  929. return TargetSystem;
  930. }
  931. BOOL Is32BitEnv()
  932. {
  933. return (BOOL) (Env == ENV_WIN32);
  934. }
  935. BOOL Is32BitDefaultEnv()
  936. {
  937. return (BOOL) (Env == ENV_WIN32) &&
  938. ! IsSwitchDefined( SWITCH_ENV );
  939. }
  940. BOOL Is64BitEnv()
  941. {
  942. return (BOOL) (Env == ENV_WIN64);
  943. }
  944. BOOL IsDoubleRunFor64()
  945. {
  946. return fDoubleFor64;
  947. }
  948. void SetDoubleRunFor64()
  949. {
  950. fDoubleFor64 = HasAppend64();
  951. }
  952. BOOL HasAppend64()
  953. {
  954. return fHasAppend64;
  955. }
  956. void SetHasAppend64( BOOL NeedsAppending )
  957. {
  958. fHasAppend64 = NeedsAppending;
  959. }
  960. BOOL Needs64Run()
  961. {
  962. return fHasAppend64;
  963. }
  964. BOOL IsNDR64Run()
  965. {
  966. return fIsNDR64Run;
  967. }
  968. void SetIsNDR64Run()
  969. {
  970. fIsNDR64Run = TRUE;
  971. }
  972. void ResetIsNDR64Run()
  973. {
  974. fIsNDR64Run = FALSE;
  975. }
  976. BOOL IsNDRRun()
  977. {
  978. return fIsNDRRun;
  979. }
  980. void SetIsNDRRun()
  981. {
  982. fIsNDRRun = TRUE;
  983. }
  984. void ResetIsNDRRun()
  985. {
  986. fIsNDRRun = FALSE;
  987. }
  988. void SetIs2ndCodegenRun()
  989. {
  990. fIs2ndCodegenRun = TRUE;
  991. }
  992. BOOL Is2ndCodegenRun()
  993. {
  994. return fIs2ndCodegenRun;
  995. }
  996. BOOL NeedsNDR64Run()
  997. {
  998. if ( TargetSyntax == SYNTAX_BOTH ||
  999. TargetSyntax == SYNTAX_NDR64 )
  1000. return TRUE;
  1001. else
  1002. return FALSE;
  1003. }
  1004. void SetNeedsNDR64Header()
  1005. {
  1006. fNeedsNDR64Header = TRUE;
  1007. }
  1008. BOOL NeedsNDR64Header()
  1009. {
  1010. return fNeedsNDR64Header;
  1011. }
  1012. BOOL IsFinalProtocolRun()
  1013. {
  1014. if ( SYNTAX_BOTH == TargetSyntax && !fIsNDR64Run )
  1015. return FALSE;
  1016. else
  1017. return TRUE;
  1018. }
  1019. // TODO: yongqu: might consider an compiler option.
  1020. SYNTAX_ENUM GetDefaultSyntax()
  1021. {
  1022. if ( TargetSyntax == SYNTAX_DCE ||
  1023. TargetSyntax == SYNTAX_BOTH )
  1024. return SYNTAX_DCE;
  1025. else
  1026. return SYNTAX_NDR64;
  1027. }
  1028. BOOL NeedsNDRRun()
  1029. {
  1030. if ( TargetSyntax == SYNTAX_BOTH ||
  1031. TargetSyntax == SYNTAX_DCE )
  1032. return TRUE;
  1033. else
  1034. return FALSE;
  1035. }
  1036. BOOL NeedsBothSyntaxes()
  1037. {
  1038. return ( TargetSyntax == SYNTAX_BOTH );
  1039. }
  1040. BOOL UseExprFormatString()
  1041. {
  1042. return IsNDR64Run();
  1043. }
  1044. BOOL NeedsNDR64DebugInfo()
  1045. {
  1046. return IsSwitchDefined(SWITCH_DEBUGINFO);
  1047. }
  1048. // get error options
  1049. short GetErrorOption()
  1050. {
  1051. return ErrorOption;
  1052. }
  1053. short WireCompat( short checkoption )
  1054. {
  1055. return WireCompatOption & checkoption;
  1056. }
  1057. // get the switch values
  1058. short GetClientSwitchValue()
  1059. {
  1060. return (short)fClient;
  1061. }
  1062. void SetClientSwitchValue( short s )
  1063. {
  1064. fClient = (unsigned char) s;
  1065. }
  1066. short GetServerSwitchValue()
  1067. {
  1068. return (short)fServer;
  1069. }
  1070. void SetServerSwitchValue( short s )
  1071. {
  1072. fServer = (unsigned char) s;
  1073. }
  1074. BOOL GenerateSStub()
  1075. {
  1076. return (fServer == SRVR_STUB) && !IsSwitchDefined( SWITCH_NO_SERVER );
  1077. }
  1078. BOOL GenerateCStub()
  1079. {
  1080. return (fClient == CLNT_STUB) && !IsSwitchDefined( SWITCH_NO_CLIENT );
  1081. }
  1082. BOOL GenerateStubs()
  1083. {
  1084. return GenerateSStub() || GenerateCStub();
  1085. }
  1086. BOOL GenerateHeader()
  1087. {
  1088. return !IsSwitchDefined( SWITCH_NO_HEADER );
  1089. }
  1090. BOOL GenerateIID()
  1091. {
  1092. return !IsSwitchDefined( SWITCH_NO_IID );
  1093. }
  1094. BOOL GenerateDllData()
  1095. {
  1096. return !IsSwitchDefined( SWITCH_NO_DLLDATA );
  1097. }
  1098. BOOL GenerateProxy()
  1099. {
  1100. return !IsSwitchDefined( SWITCH_NO_PROXY );
  1101. }
  1102. BOOL GenerateProxyDefFile()
  1103. {
  1104. return !IsSwitchDefined( SWITCH_NO_PROXY_DEF );
  1105. }
  1106. BOOL GenerateServerFile()
  1107. {
  1108. return !IsSwitchDefined( SWITCH_NO_CLASS_METHODS );
  1109. }
  1110. BOOL GenerateServerUnkFile()
  1111. {
  1112. return !IsSwitchDefined( SWITCH_NO_CLASS_IUNKNOWN );
  1113. }
  1114. BOOL GenerateServerHeaderFile()
  1115. {
  1116. return !IsSwitchDefined( SWITCH_NO_CLASS_HEADER );
  1117. }
  1118. BOOL GenerateDllServerDefFile()
  1119. {
  1120. return !IsSwitchDefined( SWITCH_NO_DLL_SERVER_DEF );
  1121. }
  1122. BOOL GenerateDllServerClassGenFile()
  1123. {
  1124. return !IsSwitchDefined( SWITCH_NO_DLL_SERVER_CLASS_GEN );
  1125. }
  1126. BOOL GenerateServerRegFile()
  1127. {
  1128. return !IsSwitchDefined( SWITCH_NO_SERVER_REG );
  1129. }
  1130. BOOL GenerateExeServerFile()
  1131. {
  1132. return !IsSwitchDefined( SWITCH_NO_EXE_SERVER );
  1133. }
  1134. BOOL GenerateExeServerMainFile()
  1135. {
  1136. return !IsSwitchDefined( SWITCH_NO_EXE_SERVER_MAIN );
  1137. }
  1138. BOOL GenerateTestFile()
  1139. {
  1140. return !IsSwitchDefined( SWITCH_NO_TESTCLIENT );
  1141. }
  1142. BOOL GenerateTypeLibrary()
  1143. {
  1144. return !IsSwitchDefined( SWITCH_NO_TLIB );
  1145. }
  1146. BOOL IsValidZeePee(long NewZeePee);
  1147. short GetZeePee()
  1148. {
  1149. return ZeePee;
  1150. }
  1151. unsigned short GetEnumSize()
  1152. {
  1153. return EnumSize;
  1154. }
  1155. void SetEnumSize(unsigned short sEnumSize)
  1156. {
  1157. EnumSize = sEnumSize;
  1158. }
  1159. unsigned long GetLocaleId()
  1160. {
  1161. return LocaleId;
  1162. }
  1163. void GetCompilerVersion(
  1164. unsigned short *pMajor,
  1165. unsigned short *pMinor,
  1166. unsigned short *pUpdate )
  1167. {
  1168. *pMajor = MajorVersion;
  1169. *pMinor = MinorVersion;
  1170. *pUpdate= UpdateNumber;
  1171. }
  1172. unsigned short GetOptimizationFlags()
  1173. {
  1174. // Don't propagate the optimize _IX flag out.
  1175. return (unsigned short) (OptimFlags & 0xff);
  1176. }
  1177. // destroys previous flags
  1178. unsigned short SetOptimizationFlags( unsigned short f )
  1179. {
  1180. return ( OptimFlags = f );
  1181. }
  1182. // preserves previous flags
  1183. unsigned short AddOptimizationFlags( unsigned short f )
  1184. {
  1185. return ( OptimFlags |= f );
  1186. }
  1187. OPT_LEVEL_ENUM GetOptimizationLevel()
  1188. {
  1189. return OptimLevel;
  1190. }
  1191. // miscellaneous flags
  1192. // get the minus I specified by the user as 1 single buffer. If the -i
  1193. // is not defined, return a null.
  1194. char * GetMinusISpecification();
  1195. BOOL IsMintRun()
  1196. {
  1197. return fMintRun;
  1198. }
  1199. unsigned short GetModeSwitchConfigMask()
  1200. {
  1201. return (unsigned short)ConfigMask;
  1202. }
  1203. void SetModeSwitchConfigMask()
  1204. {
  1205. unsigned short M = (unsigned short) ( IsSwitchDefined(SWITCH_MS_EXT) ?1:0 );
  1206. unsigned short C = (unsigned short) ( IsSwitchDefined(SWITCH_C_EXT) ?1:0 );
  1207. unsigned short A = (unsigned short) ( IsSwitchDefined(SWITCH_APP_CONFIG)?1:0 );
  1208. ConfigMask = unsigned short ( 1 << ( A * 4 + C * 2 + M ) );
  1209. }
  1210. unsigned short GetCharOption()
  1211. {
  1212. return (unsigned short)CharOption;
  1213. }
  1214. BOOL IsRpcSSAllocateEnabled()
  1215. {
  1216. return IsSwitchDefined( SWITCH_RPCSS );
  1217. }
  1218. BOOL IsNetmonStubGenerationEnabled()
  1219. {
  1220. return IsSwitchDefined( SWITCH_NETMON )
  1221. && IsSwitchDefined( SWITCH_INTERNAL );
  1222. }
  1223. char * GetUserPrefix( short index )
  1224. {
  1225. return pSwitchPrefix->GetUserDefinedEquivalent( index );
  1226. }
  1227. BOOL IsPrefixDefinedForCStub()
  1228. {
  1229. return (BOOL)
  1230. ( GetUserPrefix( PREFIX_CLIENT_STUB ) != 0 );
  1231. }
  1232. BOOL IsPrefixDefinedForSStub()
  1233. {
  1234. return (BOOL)
  1235. ( GetUserPrefix( PREFIX_SERVER_MGR ) != 0 );
  1236. }
  1237. char* GetCompilerVersion()
  1238. {
  1239. return szCompilerVersion;
  1240. }
  1241. // note that this string ends with a newline.
  1242. char* GetCompileTime()
  1243. {
  1244. return szCompileTime;
  1245. }
  1246. BOOL IsPrefixDifferentForStubs();
  1247. void EmitConfirm( ISTREAM * pStream );
  1248. STATUS_T StreamIn( char* );
  1249. void StreamOut( STREAM* );
  1250. NdrVersionControl & GetNdrVersionControl()
  1251. {
  1252. return VersionControl;
  1253. }
  1254. void VerifyTargetSwitch();
  1255. } CMD_ARG;
  1256. typedef unsigned long ulong;
  1257. extern CMD_ARG* pCommand;
  1258. #endif // __CMDANA_HXX__