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.

1552 lines
54 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. fHasMsExt64 ||
  667. fHasForceAllocate ||
  668. fHasPartialIgnore ||
  669. TargetSystem >= NT51;
  670. }
  671. BOOL IsNdr60orLaterRequired()
  672. {
  673. return HasNdr60Feature();
  674. }
  675. BOOL IsNdr50orLaterRequired()
  676. {
  677. return HasNdr50Feature();
  678. }
  679. void SetTargetSystem( TARGET_ENUM target )
  680. {
  681. TargetSystem = target;
  682. }
  683. TARGET_ENUM GetTargetSystem()
  684. {
  685. return TargetSystem;
  686. }
  687. BOOL TargetIsNT40OrLater()
  688. {
  689. return (TargetSystem >= NT40);
  690. }
  691. BOOL TargetIsNT50OrLater()
  692. {
  693. return (TargetSystem >= NT50);
  694. }
  695. BOOL TargetIsLessThanNT50()
  696. {
  697. return ( NOTARGET != TargetSystem )
  698. && ( TargetSystem < NT50 );
  699. }
  700. BOOL TargetIsNT51OrLater()
  701. {
  702. return (TargetSystem >= NT51);
  703. }
  704. BOOL TargetIsLessThanNT51()
  705. {
  706. return ( NOTARGET != TargetSystem )
  707. && ( TargetSystem < NT51 );
  708. }
  709. BOOL AllowIntrepretedComplexReturns()
  710. {
  711. return HasMultiTransferSyntax();
  712. }
  713. };
  714. /////////////////////////////////////////////////////////////////////////////
  715. // the big boy - the command analyser object
  716. /////////////////////////////////////////////////////////////////////////////
  717. typedef class _cmd_arg
  718. {
  719. protected:
  720. unsigned long switch_def_vector[ 5 ]; // switch definition vector
  721. unsigned char fClient; // client switch options
  722. unsigned char fServer; // server switch options
  723. unsigned char Env; // env - flat /segmented
  724. unsigned char CharOption; // char option
  725. unsigned char fMintRun; // this is a mint ( MIDL-lint) run
  726. unsigned short MajorVersion; // major version
  727. unsigned short MinorVersion; // minor version
  728. unsigned short UpdateNumber; // update
  729. unsigned short ErrorOption; // error option
  730. unsigned short WireCompatOption; // wire_compat options
  731. unsigned short ConfigMask; // configuration mask for error reporting
  732. unsigned short MSCVersion; // MS C Compiler version
  733. bool fShowLogo;
  734. NdrVersionControl VersionControl; // compiler evaluation
  735. unsigned short OptimFlags; // optimization flags from user
  736. OPT_LEVEL_ENUM OptimLevel; // internal optimization level
  737. TARGET_ENUM TargetSystem; // targeted system
  738. SYNTAX_ENUM TargetSyntax;
  739. short iArgV; // index into the argument vector
  740. short cArgs; // count of arguments
  741. short WLevel; // warning level
  742. unsigned short ZeePee; // the Zp switch option value
  743. unsigned short EnumSize; // memory size of enum16
  744. unsigned long LocaleId; // the lcid for MBCS
  745. BOOL fDoubleFor64; // double run marker
  746. BOOL fHasAppend64; // the 64 append run
  747. BOOL fIsNDR64Run; // NDR64 run
  748. BOOL fIsNDRRun; // NDR run
  749. BOOL fIs2ndCodegenRun; // protocol all
  750. BOOL fNeedsNDR64Header; // protocol all, no -env, 32bit
  751. char szCompileTime[32];
  752. char szCompilerVersion[32];
  753. filename_switch * pInputFNSwitch, // input file name
  754. * pOutputPathSwitch, // output path
  755. * pCStubSwitch, // cstub
  756. * pSStubSwitch, // sstub
  757. * pHeaderSwitch, // header
  758. * pAcfSwitch, // acf
  759. * pIIDSwitch, // iid
  760. * pDllDataSwitch, // dlldata
  761. * pProxySwitch, // proxy
  762. * pProxyDefSwitch, // proxy
  763. * pTlibSwitch, // Type Library file name
  764. * pNetmonStubSwitch, // Netmon stub file
  765. * pNetmonStubObjSwitch, // Netmon stub file
  766. * pRedirectOutputSwitch; // redirect stdout to this file
  767. pair_switch * pSwitchPrefix; // -prefix
  768. pair_switch * pSwitchSuffix; // -suffix
  769. multiple_switch * pDSwitch, // -D
  770. * pISwitch, // -I
  771. * pUSwitch; // -U
  772. onetime_switch * pCppCmdSwitch, // cpp_cmd
  773. * pCppOptSwitch, // cpp_opt
  774. * pMSCVerSwitch, // msc_ver
  775. * pDebug64Switch, // debug64
  776. * pDebug64OptSwitch; // debug64_opt
  777. public:
  778. _cmd_arg();
  779. // Is the switch defined ?
  780. BOOL IsSwitchDefined( short SWNo )
  781. {
  782. unsigned long sw = switch_def_vector[ SWNo / 32 ];
  783. unsigned long temp = SWNo % 32;
  784. sw = sw & ( (unsigned long)1 << temp );
  785. return sw ? (BOOL)1 : (BOOL)0;
  786. }
  787. // Set the switch to be defined.
  788. void SwitchDefined( short );
  789. // Get filename.
  790. char * GetInputFileName()
  791. {
  792. return pInputFNSwitch->GetFileName();
  793. }
  794. void GetInputFileNameComponents(
  795. char *pD, // drive buffer
  796. char *pP, // path buffer
  797. char *pN, // base name buffer
  798. char *pE // extension buffer
  799. )
  800. {
  801. pInputFNSwitch->GetFileNameComponents( pD,
  802. pP,
  803. pN,
  804. pE );
  805. }
  806. char * GetAcfFileName()
  807. {
  808. return pAcfSwitch->GetFileName();
  809. }
  810. void GetAcfFileNameComponents(
  811. char *pD,
  812. char *pP,
  813. char *pN,
  814. char *pE )
  815. {
  816. pAcfSwitch->GetFileNameComponents( pD,
  817. pP,
  818. pN,
  819. pE );
  820. }
  821. char * GetOutputPath();
  822. char * GetCstubFName()
  823. {
  824. return pCStubSwitch->GetFileName();
  825. }
  826. void GetCstubFileNameComponents(
  827. char *pD,
  828. char *pP,
  829. char *pN,
  830. char *pE )
  831. {
  832. pCStubSwitch->GetFileNameComponents( pD,
  833. pP,
  834. pN,
  835. pE );
  836. }
  837. char * GetSstubFName()
  838. {
  839. return pSStubSwitch->GetFileName();
  840. }
  841. void GetSstubFileNameComponents(
  842. char *pD,
  843. char *pP,
  844. char *pN,
  845. char *pE )
  846. {
  847. pSStubSwitch->GetFileNameComponents( pD,
  848. pP,
  849. pN,
  850. pE );
  851. }
  852. char * GetHeader()
  853. {
  854. return pHeaderSwitch->GetFileName();
  855. }
  856. void GetHeaderFileNameComponents(
  857. char *pD,
  858. char *pP,
  859. char *pN,
  860. char *pE )
  861. {
  862. pHeaderSwitch->GetFileNameComponents( pD,
  863. pP,
  864. pN,
  865. pE );
  866. }
  867. char * GetIIDFName()
  868. {
  869. return pIIDSwitch->GetFileName();
  870. }
  871. char * GetDllDataFName()
  872. {
  873. return pDllDataSwitch->GetFileName();
  874. }
  875. char * GetProxyFName()
  876. {
  877. return pProxySwitch->GetFileName();
  878. }
  879. char * GetTypeLibraryFName()
  880. {
  881. return pTlibSwitch->GetFileName();
  882. }
  883. char * GetNetmonStubFName()
  884. {
  885. return pNetmonStubSwitch->GetFileName();
  886. }
  887. char * GetNetmonStubObjFName()
  888. {
  889. return pNetmonStubObjSwitch->GetFileName();
  890. }
  891. // get preprocessor command
  892. char * GetCPPCmd()
  893. {
  894. return pCppCmdSwitch->GetOption();
  895. }
  896. // get preprocessor options
  897. char * GetCPPOpt()
  898. {
  899. return pCppOptSwitch->GetOption();
  900. }
  901. bool ShowLogo()
  902. {
  903. return fShowLogo;
  904. }
  905. unsigned short GetMSCVer()
  906. {
  907. return MSCVersion;
  908. }
  909. char * GetDebug64()
  910. {
  911. return pDebug64Switch->GetOption();
  912. }
  913. char * GetDebug64Opt()
  914. {
  915. return pDebug64OptSwitch->GetOption();
  916. }
  917. // get warning level
  918. short GetWarningLevel() { return WLevel; };
  919. // get env switch value
  920. short GetEnv()
  921. {
  922. return (short)Env;
  923. }
  924. void SetEnv( int env )
  925. {
  926. Env = (unsigned char) env;
  927. }
  928. TARGET_ENUM GetTargetSystem()
  929. {
  930. return TargetSystem;
  931. }
  932. BOOL Is32BitEnv()
  933. {
  934. return (BOOL) (Env == ENV_WIN32);
  935. }
  936. BOOL Is32BitDefaultEnv()
  937. {
  938. return (BOOL) (Env == ENV_WIN32) &&
  939. ! IsSwitchDefined( SWITCH_ENV );
  940. }
  941. BOOL Is64BitEnv()
  942. {
  943. return (BOOL) (Env == ENV_WIN64);
  944. }
  945. BOOL IsDoubleRunFor64()
  946. {
  947. return fDoubleFor64;
  948. }
  949. void SetDoubleRunFor64()
  950. {
  951. fDoubleFor64 = HasAppend64();
  952. }
  953. BOOL HasAppend64()
  954. {
  955. return fHasAppend64;
  956. }
  957. void SetHasAppend64( BOOL NeedsAppending )
  958. {
  959. fHasAppend64 = NeedsAppending;
  960. }
  961. BOOL Needs64Run()
  962. {
  963. return fHasAppend64;
  964. }
  965. BOOL IsNDR64Run()
  966. {
  967. return fIsNDR64Run;
  968. }
  969. void SetIsNDR64Run()
  970. {
  971. fIsNDR64Run = TRUE;
  972. }
  973. void ResetIsNDR64Run()
  974. {
  975. fIsNDR64Run = FALSE;
  976. }
  977. BOOL IsNDRRun()
  978. {
  979. return fIsNDRRun;
  980. }
  981. void SetIsNDRRun()
  982. {
  983. fIsNDRRun = TRUE;
  984. }
  985. void ResetIsNDRRun()
  986. {
  987. fIsNDRRun = FALSE;
  988. }
  989. void SetIs2ndCodegenRun()
  990. {
  991. fIs2ndCodegenRun = TRUE;
  992. }
  993. BOOL Is2ndCodegenRun()
  994. {
  995. return fIs2ndCodegenRun;
  996. }
  997. BOOL NeedsNDR64Run()
  998. {
  999. if ( TargetSyntax == SYNTAX_BOTH ||
  1000. TargetSyntax == SYNTAX_NDR64 )
  1001. return TRUE;
  1002. else
  1003. return FALSE;
  1004. }
  1005. void SetNeedsNDR64Header()
  1006. {
  1007. fNeedsNDR64Header = TRUE;
  1008. }
  1009. BOOL NeedsNDR64Header()
  1010. {
  1011. return fNeedsNDR64Header;
  1012. }
  1013. BOOL IsFinalProtocolRun()
  1014. {
  1015. if ( SYNTAX_BOTH == TargetSyntax && !fIsNDR64Run )
  1016. return FALSE;
  1017. else
  1018. return TRUE;
  1019. }
  1020. // TODO: yongqu: might consider an compiler option.
  1021. SYNTAX_ENUM GetDefaultSyntax()
  1022. {
  1023. if ( TargetSyntax == SYNTAX_DCE ||
  1024. TargetSyntax == SYNTAX_BOTH )
  1025. return SYNTAX_DCE;
  1026. else
  1027. return SYNTAX_NDR64;
  1028. }
  1029. BOOL NeedsNDRRun()
  1030. {
  1031. if ( TargetSyntax == SYNTAX_BOTH ||
  1032. TargetSyntax == SYNTAX_DCE )
  1033. return TRUE;
  1034. else
  1035. return FALSE;
  1036. }
  1037. BOOL NeedsBothSyntaxes()
  1038. {
  1039. return ( TargetSyntax == SYNTAX_BOTH );
  1040. }
  1041. BOOL UseExprFormatString()
  1042. {
  1043. return IsNDR64Run();
  1044. }
  1045. BOOL NeedsNDR64DebugInfo()
  1046. {
  1047. return IsSwitchDefined(SWITCH_DEBUGINFO);
  1048. }
  1049. // get error options
  1050. short GetErrorOption()
  1051. {
  1052. return ErrorOption;
  1053. }
  1054. short WireCompat( short checkoption )
  1055. {
  1056. return WireCompatOption & checkoption;
  1057. }
  1058. // get the switch values
  1059. short GetClientSwitchValue()
  1060. {
  1061. return (short)fClient;
  1062. }
  1063. void SetClientSwitchValue( short s )
  1064. {
  1065. fClient = (unsigned char) s;
  1066. }
  1067. short GetServerSwitchValue()
  1068. {
  1069. return (short)fServer;
  1070. }
  1071. void SetServerSwitchValue( short s )
  1072. {
  1073. fServer = (unsigned char) s;
  1074. }
  1075. BOOL GenerateSStub()
  1076. {
  1077. return (fServer == SRVR_STUB) && !IsSwitchDefined( SWITCH_NO_SERVER );
  1078. }
  1079. BOOL GenerateCStub()
  1080. {
  1081. return (fClient == CLNT_STUB) && !IsSwitchDefined( SWITCH_NO_CLIENT );
  1082. }
  1083. BOOL GenerateStubs()
  1084. {
  1085. return GenerateSStub() || GenerateCStub();
  1086. }
  1087. BOOL GenerateHeader()
  1088. {
  1089. return !IsSwitchDefined( SWITCH_NO_HEADER );
  1090. }
  1091. BOOL GenerateIID()
  1092. {
  1093. return !IsSwitchDefined( SWITCH_NO_IID );
  1094. }
  1095. BOOL GenerateDllData()
  1096. {
  1097. return !IsSwitchDefined( SWITCH_NO_DLLDATA );
  1098. }
  1099. BOOL GenerateProxy()
  1100. {
  1101. return !IsSwitchDefined( SWITCH_NO_PROXY );
  1102. }
  1103. BOOL GenerateProxyDefFile()
  1104. {
  1105. return !IsSwitchDefined( SWITCH_NO_PROXY_DEF );
  1106. }
  1107. BOOL GenerateServerFile()
  1108. {
  1109. return !IsSwitchDefined( SWITCH_NO_CLASS_METHODS );
  1110. }
  1111. BOOL GenerateServerUnkFile()
  1112. {
  1113. return !IsSwitchDefined( SWITCH_NO_CLASS_IUNKNOWN );
  1114. }
  1115. BOOL GenerateServerHeaderFile()
  1116. {
  1117. return !IsSwitchDefined( SWITCH_NO_CLASS_HEADER );
  1118. }
  1119. BOOL GenerateDllServerDefFile()
  1120. {
  1121. return !IsSwitchDefined( SWITCH_NO_DLL_SERVER_DEF );
  1122. }
  1123. BOOL GenerateDllServerClassGenFile()
  1124. {
  1125. return !IsSwitchDefined( SWITCH_NO_DLL_SERVER_CLASS_GEN );
  1126. }
  1127. BOOL GenerateServerRegFile()
  1128. {
  1129. return !IsSwitchDefined( SWITCH_NO_SERVER_REG );
  1130. }
  1131. BOOL GenerateExeServerFile()
  1132. {
  1133. return !IsSwitchDefined( SWITCH_NO_EXE_SERVER );
  1134. }
  1135. BOOL GenerateExeServerMainFile()
  1136. {
  1137. return !IsSwitchDefined( SWITCH_NO_EXE_SERVER_MAIN );
  1138. }
  1139. BOOL GenerateTestFile()
  1140. {
  1141. return !IsSwitchDefined( SWITCH_NO_TESTCLIENT );
  1142. }
  1143. BOOL GenerateTypeLibrary()
  1144. {
  1145. return !IsSwitchDefined( SWITCH_NO_TLIB );
  1146. }
  1147. BOOL IsValidZeePee(long NewZeePee);
  1148. short GetZeePee()
  1149. {
  1150. return ZeePee;
  1151. }
  1152. unsigned short GetEnumSize()
  1153. {
  1154. return EnumSize;
  1155. }
  1156. void SetEnumSize(unsigned short sEnumSize)
  1157. {
  1158. EnumSize = sEnumSize;
  1159. }
  1160. unsigned long GetLocaleId()
  1161. {
  1162. return LocaleId;
  1163. }
  1164. void GetCompilerVersion(
  1165. unsigned short *pMajor,
  1166. unsigned short *pMinor,
  1167. unsigned short *pUpdate )
  1168. {
  1169. *pMajor = MajorVersion;
  1170. *pMinor = MinorVersion;
  1171. *pUpdate= UpdateNumber;
  1172. }
  1173. unsigned short GetOptimizationFlags()
  1174. {
  1175. // Don't propagate the optimize _IX flag out.
  1176. return (unsigned short) (OptimFlags & 0xff);
  1177. }
  1178. // destroys previous flags
  1179. unsigned short SetOptimizationFlags( unsigned short f )
  1180. {
  1181. return ( OptimFlags = f );
  1182. }
  1183. // preserves previous flags
  1184. unsigned short AddOptimizationFlags( unsigned short f )
  1185. {
  1186. return ( OptimFlags |= f );
  1187. }
  1188. OPT_LEVEL_ENUM GetOptimizationLevel()
  1189. {
  1190. return OptimLevel;
  1191. }
  1192. // miscellaneous flags
  1193. // get the minus I specified by the user as 1 single buffer. If the -i
  1194. // is not defined, return a null.
  1195. char * GetMinusISpecification();
  1196. BOOL IsMintRun()
  1197. {
  1198. return fMintRun;
  1199. }
  1200. unsigned short GetModeSwitchConfigMask()
  1201. {
  1202. return (unsigned short)ConfigMask;
  1203. }
  1204. void SetModeSwitchConfigMask()
  1205. {
  1206. unsigned short M = (unsigned short) ( IsSwitchDefined(SWITCH_MS_EXT) ?1:0 );
  1207. unsigned short C = (unsigned short) ( IsSwitchDefined(SWITCH_C_EXT) ?1:0 );
  1208. unsigned short A = (unsigned short) ( IsSwitchDefined(SWITCH_APP_CONFIG)?1:0 );
  1209. ConfigMask = unsigned short ( 1 << ( A * 4 + C * 2 + M ) );
  1210. }
  1211. unsigned short GetCharOption()
  1212. {
  1213. return (unsigned short)CharOption;
  1214. }
  1215. BOOL IsRpcSSAllocateEnabled()
  1216. {
  1217. return IsSwitchDefined( SWITCH_RPCSS );
  1218. }
  1219. BOOL IsNetmonStubGenerationEnabled()
  1220. {
  1221. return IsSwitchDefined( SWITCH_NETMON )
  1222. && IsSwitchDefined( SWITCH_INTERNAL );
  1223. }
  1224. char * GetUserPrefix( short index )
  1225. {
  1226. return pSwitchPrefix->GetUserDefinedEquivalent( index );
  1227. }
  1228. BOOL IsPrefixDefinedForCStub()
  1229. {
  1230. return (BOOL)
  1231. ( GetUserPrefix( PREFIX_CLIENT_STUB ) != 0 );
  1232. }
  1233. BOOL IsPrefixDefinedForSStub()
  1234. {
  1235. return (BOOL)
  1236. ( GetUserPrefix( PREFIX_SERVER_MGR ) != 0 );
  1237. }
  1238. char* GetCompilerVersion()
  1239. {
  1240. return szCompilerVersion;
  1241. }
  1242. // note that this string ends with a newline.
  1243. char* GetCompileTime()
  1244. {
  1245. return szCompileTime;
  1246. }
  1247. BOOL IsPrefixDifferentForStubs();
  1248. void EmitConfirm( ISTREAM * pStream );
  1249. STATUS_T StreamIn( char* );
  1250. void StreamOut( STREAM* );
  1251. NdrVersionControl & GetNdrVersionControl()
  1252. {
  1253. return VersionControl;
  1254. }
  1255. } CMD_ARG;
  1256. typedef unsigned long ulong;
  1257. extern CMD_ARG* pCommand;
  1258. #endif // __CMDANA_HXX__