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.

1697 lines
31 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. ARGUMENT_LEXEMIZER
  5. Abstract:
  6. This module contains the definition for the ARGUMENT_LEXEMIZER
  7. class. The argument lexemizer is the engine of command-line
  8. argument parsing.
  9. Author:
  10. steve rowe stever 2/1/91
  11. Environment:
  12. user
  13. Notes:
  14. The argument lexemizer divides the command line arguments into
  15. a series of lexemes, which are then matched argument patterns.
  16. The way in which the command line is lexed is determined by
  17. a few parameters, which are user-settable:
  18. * White space
  19. * Switch characters
  20. * Separators
  21. * Start of quote
  22. * End of quote
  23. * Multiple switches (i.e. what switches can be grouped)
  24. * Metacharacters (used to escape the following character)
  25. * Case sensitivity for switches
  26. * "Glomming" of switches (see note at "GLOMMING").
  27. * No space between tokens (specifically for xcopy)
  28. The class provides defaults for all of the above.
  29. After the command line has been lexed, the lexemizer is
  30. given an ARRAY of argument objects. Each argument provides:
  31. 1.- A pattern to match
  32. 2.- A method for setting the argument value
  33. The lexemizer will try to match each lexeme agains all the
  34. arguments. When a match is found, the corresponding argument
  35. value is set, the lexeme is consumed and it proceeds with the
  36. next lexeme.
  37. Schematically:
  38. < Command Line >
  39. |
  40. | Argument
  41. | ARRAY
  42. v __________
  43. +-----------+ [__________]
  44. Settings--->| Lexemizer |<-------> [__________]
  45. +-----------+ ^ [__________]
  46. |
  47. |
  48. v
  49. ( Matcher )
  50. The matcher will try to match the lexeme provided by the
  51. lexemizer and the pattern provided by the argument. If they
  52. match, then the matcher asks the argument to set its value
  53. (at this point, the argument might consume more lexemes from
  54. the lexemizer). If the argument does not set its value, then
  55. we will consider this a "no match", and the lexemizer will
  56. try to match the lexeme against the following argument in
  57. the ARRAY.
  58. So, this is how to use this thing:
  59. 1.- Initialize the lexemizer (with an empty ARRAY object):
  60. ARGUMENT_LEXEMIZER ArgLex;
  61. ARRAY SomeEmtpyArray;
  62. SomeEmtryArray->Initialize();
  63. ArgLex->Initialize(&SomeEmptyArray);
  64. 2.- If we don't like some default, we change it:
  65. ArgLex->PutSwitches("-/");
  66. ArgLex->PutMetaCharacters("^");
  67. 3.- Prepare the lexemizer for parsing. If we don't provide
  68. a command line, it will take it from the environment.
  69. ArgLex->PrepareToParse();
  70. 4.- Define the arguments that our application will accept.
  71. Initialize them with the pattern that they will match.
  72. Put the argument in an ARRAY object. Note that the order
  73. in which the arguments are in the array is important, since
  74. that is the order in which they are matched.
  75. ARRAY ArrayOfArg;
  76. FLAG_ARGUMENT ArgRecursive; // Recursive flag
  77. FLAG_ARGUMENT ArgVerbose; // Verbose flag
  78. ArrayOfArg->Initialize();
  79. ArgRecursive->Initialize("/R");
  80. ArgVerbose->Initialize("/V");
  81. ArrayOfArg->Put(&ArgRecursive);
  82. ArrayOfArg->Put(&ArgVerbose);
  83. 5.- Now let the lexemizer parse the arguments. If the parsing
  84. returns TRUE, then all the command line was parsed correctly,
  85. if it returns FALSE, then an error was found (e.g. invalid
  86. argument):
  87. if (!(ArgLex->DoParsing(&ArrayOfArg))) {
  88. //
  89. // Error, display usage
  90. //
  91. Usage();
  92. }
  93. 6.- Voila! We can now query our arguments for their value:
  94. .
  95. .
  96. .
  97. if (ArgRecursive->QueryFlag()) {
  98. .
  99. .
  100. Do_recursive_stuff();
  101. .
  102. .
  103. Warnings:
  104. * The strings passed when setting options (such as switch
  105. characters) have to remain in scope while the lexemizer is
  106. being used, because the lexemizer keeps pointers to them.
  107. * If after parsing the command line you want to change some
  108. setting and parse the line again, you have to call the
  109. PrepareToParse method after changing the setting and before
  110. calling the DoParsing method. Note that in this case you
  111. might want to use "fresh" argument objects, because most
  112. arguments can only be set once.
  113. * The method for querying the value of an argument is
  114. argument-specific (no virtual method is provided).
  115. * GLOMMING (mjb): This is something of a kludge I added to
  116. allow xcopy to take switch arguments glommed together, as
  117. in "/s/f/i/d" while not being confused by date arguments
  118. such as "/d:8/24/95". This is handled similarly to the
  119. "multiple switches"; only switches that are allowed to be
  120. grouped may be glommed.
  121. * NoSpcBetweenDstAndSwitch: This is a kludge to allow xcopy
  122. to accept a destination path and a switch with no space
  123. in between. The trick is to avoid being confused by date
  124. arguments such as "/d:8/24/95".
  125. Revision History:
  126. --*/
  127. #include "array.hxx"
  128. #include "wstring.hxx"
  129. #if !defined( _AUTOCHECK_ )
  130. #include "timeinfo.hxx"
  131. #include "path.hxx"
  132. #endif
  133. //
  134. // Forward references
  135. //
  136. #if !defined (_ARGUMENT_LEXEMIZER_)
  137. #define _ARGUMENT_LEXEMIZER_
  138. DECLARE_CLASS( ARGUMENT_LEXEMIZER );
  139. DECLARE_CLASS( ARGUMENT );
  140. // Type of a pointer to the match function
  141. //
  142. typedef BOOLEAN (*PMATCHFUNCTION)(OUT PARGUMENT, OUT PARGUMENT_LEXEMIZER);
  143. class ARGUMENT_LEXEMIZER : public OBJECT {
  144. public:
  145. ULIB_EXPORT
  146. DECLARE_CONSTRUCTOR( ARGUMENT_LEXEMIZER );
  147. VIRTUAL
  148. ULIB_EXPORT
  149. ~ARGUMENT_LEXEMIZER(
  150. );
  151. NONVIRTUAL
  152. ULIB_EXPORT
  153. BOOLEAN
  154. Initialize (
  155. IN PARRAY LexemeArray
  156. );
  157. NONVIRTUAL
  158. ULIB_EXPORT
  159. BOOLEAN
  160. DoParsing (
  161. IN PARRAY ArgumentArray
  162. );
  163. NONVIRTUAL
  164. ULIB_EXPORT
  165. PWSTRING
  166. GetLexemeAt (
  167. IN ULONG Index
  168. );
  169. NONVIRTUAL
  170. ULONG
  171. IncrementConsumedCount (
  172. IN ULONG HowMany DEFAULT 1
  173. );
  174. VOID
  175. PutEndQuotes (
  176. IN PCWSTRING QuoteChars
  177. );
  178. VOID
  179. PutEndQuotes (
  180. IN PCSTR QuoteChars
  181. );
  182. NONVIRTUAL
  183. VOID
  184. PutMetaChars (
  185. IN PCSTR MetaChars
  186. );
  187. NONVIRTUAL
  188. VOID
  189. PutMetaChars (
  190. IN PCWSTRING MetaChars
  191. );
  192. NONVIRTUAL
  193. ULIB_EXPORT
  194. VOID
  195. PutMultipleSwitch (
  196. IN PCSTR MultipleSwitch
  197. );
  198. NONVIRTUAL
  199. ULIB_EXPORT
  200. VOID
  201. PutMultipleSwitch (
  202. IN PCWSTRING MultipleSwitch
  203. );
  204. NONVIRTUAL
  205. ULIB_EXPORT
  206. VOID
  207. PutSeparators (
  208. IN PCSTR Separators
  209. );
  210. NONVIRTUAL
  211. VOID
  212. PutSeparators (
  213. IN PCWSTRING Separators
  214. );
  215. VOID
  216. PutStartQuotes (
  217. IN PCSTR QuoteChars
  218. );
  219. VOID
  220. PutStartQuotes (
  221. IN PCWSTRING QuoteChars
  222. );
  223. NONVIRTUAL
  224. ULIB_EXPORT
  225. VOID
  226. PutSwitches (
  227. IN PCSTR Switches
  228. );
  229. NONVIRTUAL
  230. ULIB_EXPORT
  231. VOID
  232. PutSwitches (
  233. IN PCWSTRING Switches
  234. );
  235. NONVIRTUAL
  236. PCWSTRING
  237. GetSwitches (
  238. );
  239. NONVIRTUAL
  240. CHNUM
  241. QueryCharPos (
  242. IN ULONG LexemeNumber
  243. );
  244. NONVIRTUAL
  245. ULONG
  246. QueryConsumedCount (
  247. );
  248. NONVIRTUAL
  249. ULONG
  250. QueryLexemeCount (
  251. ) CONST;
  252. NONVIRTUAL
  253. ULIB_EXPORT
  254. PWSTRING
  255. QueryInvalidArgument (
  256. );
  257. NONVIRTUAL
  258. ULIB_EXPORT
  259. BOOLEAN
  260. PrepareToParse (
  261. IN PWSTRING CommandLine DEFAULT NULL
  262. );
  263. NONVIRTUAL
  264. ULIB_EXPORT
  265. VOID
  266. SetCaseSensitive (
  267. BOOLEAN CaseSensitive
  268. );
  269. NONVIRTUAL
  270. PCWSTRING
  271. GetCmdLine(
  272. ) CONST;
  273. NONVIRTUAL
  274. ULIB_EXPORT
  275. VOID
  276. SetAllowSwitchGlomming (
  277. BOOLEAN AllowGlomming
  278. );
  279. NONVIRTUAL
  280. ULIB_EXPORT
  281. VOID
  282. SetNoSpcBetweenDstAndSwitch (
  283. BOOLEAN NoSpcBetweenDstAndSwitch
  284. );
  285. private:
  286. NONVIRTUAL
  287. VOID
  288. Construct (
  289. );
  290. NONVIRTUAL
  291. BOOLEAN
  292. PutCharPos (
  293. IN ULONG Position,
  294. IN CHNUM CharPos
  295. );
  296. PARRAY _parray; // Array of lexemes
  297. PCHNUM _CharPos; // Character positions
  298. ULONG _CharPosSize; // Size of _CharPos array
  299. ULONG _ConsumedCount; // Lexemes consumed
  300. ULONG _LexemeCount; // Total lexemes
  301. DSTRING _WhiteSpace; // White space characters
  302. DSTRING _SwitchChars; // Switch characters
  303. DSTRING _Separators; // Separator characters
  304. DSTRING _StartQuote; // Start of quote characters
  305. DSTRING _SeparatorString; // All characters which cause separation
  306. DSTRING _EndQuote; // End of quote characters
  307. DSTRING _MultipleSwitches; // "Groupable" switches
  308. DSTRING _MetaChars; // Meta-characters
  309. BOOLEAN _CaseSensitive; // TRUE if case sensitive
  310. BOOLEAN _AllowGlomming; // TRUE if switch glomming allowed
  311. BOOLEAN _NoSpcBetweenDstAndSwitch; // TRUE if no space is required
  312. // between tokens
  313. WCHAR _Switch; // Switch character
  314. DSTRING _CmdLine; // The entire command line
  315. };
  316. INLINE
  317. PCWSTRING
  318. ARGUMENT_LEXEMIZER::GetSwitches (
  319. )
  320. /*++
  321. Routine Description:
  322. Returns a ptr to a string containing the valid switch chars
  323. Arguments:
  324. none
  325. Return Value:
  326. Returns string containing the valid switch chars
  327. --*/
  328. {
  329. return &_SwitchChars;
  330. }
  331. INLINE
  332. ULONG
  333. ARGUMENT_LEXEMIZER::IncrementConsumedCount (
  334. IN ULONG HowMany
  335. )
  336. /*++
  337. Routine Description:
  338. Increments count of Lexemes consumed
  339. Arguments:
  340. HowMany - Supplies by how many to increment.
  341. Return Value:
  342. New count
  343. --*/
  344. {
  345. return (_ConsumedCount += HowMany);
  346. }
  347. INLINE
  348. VOID
  349. ARGUMENT_LEXEMIZER::PutEndQuotes (
  350. IN PCSTR QuoteChars
  351. )
  352. /*++
  353. Routine Description:
  354. Initializes the ending quote chars
  355. Arguments:
  356. QuoteChars - Supplies pointer to string of close quote chars
  357. Return Value:
  358. none
  359. --*/
  360. {
  361. DebugPtrAssert( QuoteChars );
  362. _EndQuote.Initialize(QuoteChars);
  363. }
  364. INLINE
  365. VOID
  366. ARGUMENT_LEXEMIZER::PutEndQuotes (
  367. IN PCWSTRING QuoteChars
  368. )
  369. /*++
  370. Routine Description:
  371. Initializes the ending quote chars
  372. Arguments:
  373. QuoteChars - Supplies pointer to string of close quote chars
  374. Return Value:
  375. none
  376. --*/
  377. {
  378. DebugPtrAssert( QuoteChars );
  379. _EndQuote.Initialize(QuoteChars);
  380. }
  381. INLINE
  382. VOID
  383. ARGUMENT_LEXEMIZER::PutStartQuotes (
  384. IN PCSTR QuoteChars
  385. )
  386. /*++
  387. Routine Description:
  388. Initializes the starting quote chars
  389. Arguments:
  390. QuoteChars - Supplies pointer to string of open quote chars
  391. Return Value:
  392. none
  393. --*/
  394. {
  395. DebugPtrAssert( QuoteChars );
  396. _StartQuote.Initialize(QuoteChars);
  397. }
  398. INLINE
  399. VOID
  400. ARGUMENT_LEXEMIZER::PutStartQuotes (
  401. IN PCWSTRING QuoteChars
  402. )
  403. /*++
  404. Routine Description:
  405. Initializes the starting quote chars
  406. Arguments:
  407. QuoteChars - Supplies pointer to string of open quote chars
  408. Return Value:
  409. none
  410. --*/
  411. {
  412. DebugPtrAssert( QuoteChars );
  413. _StartQuote.Initialize(QuoteChars);
  414. }
  415. INLINE
  416. ULONG
  417. ARGUMENT_LEXEMIZER::QueryConsumedCount (
  418. )
  419. /*++
  420. Routine Description:
  421. Returns number of lexemes consumed
  422. Arguments:
  423. none
  424. Return Value:
  425. Number of lexemes consumed
  426. --*/
  427. {
  428. return _ConsumedCount;
  429. }
  430. INLINE
  431. ULONG
  432. ARGUMENT_LEXEMIZER::QueryLexemeCount (
  433. ) CONST
  434. /*++
  435. Routine Description:
  436. Returns total number of lexemes
  437. Arguments:
  438. none
  439. Return Value:
  440. Total number of lexemes
  441. --*/
  442. {
  443. return _LexemeCount;
  444. }
  445. INLINE
  446. PCWSTRING
  447. ARGUMENT_LEXEMIZER::GetCmdLine(
  448. ) CONST
  449. /*++
  450. Routine Description:
  451. Returns the original commmand line.
  452. Arguments:
  453. None.
  454. Return Value:
  455. The original command line.
  456. --*/
  457. {
  458. return &_CmdLine;
  459. }
  460. #endif // _ARGUMENT_LEXEMIZER_
  461. /*++
  462. Copyright (c) 1990 Microsoft Corporation
  463. Module Name:
  464. ARGUMENT
  465. Abstract:
  466. Base class for arguments.
  467. Author:
  468. steve rowe stever 2/1/91
  469. [Environment:]
  470. optional-environment-info (e.g. kernel mode only...)
  471. Notes:
  472. Revision History:
  473. --*/
  474. #if !defined (_ARGUMENT_)
  475. #define _ARGUMENT_
  476. class ARGUMENT : public OBJECT {
  477. public:
  478. DECLARE_CONSTRUCTOR( ARGUMENT );
  479. NONVIRTUAL
  480. BOOLEAN
  481. Initialize (
  482. IN PSTR Pattern
  483. );
  484. NONVIRTUAL
  485. BOOLEAN
  486. Initialize (
  487. IN PWSTRING Pattern
  488. );
  489. NONVIRTUAL
  490. ULIB_EXPORT
  491. PWSTRING
  492. GetLexeme (
  493. );
  494. NONVIRTUAL
  495. ULIB_EXPORT
  496. PWSTRING
  497. GetPattern (
  498. );
  499. NONVIRTUAL
  500. ULIB_EXPORT
  501. BOOLEAN
  502. IsValueSet (
  503. );
  504. VIRTUAL
  505. BOOLEAN
  506. SetIfMatch (
  507. OUT PARGUMENT_LEXEMIZER ArgumentLexemizer,
  508. IN BOOLEAN CaseSensitive
  509. );
  510. VIRTUAL
  511. BOOLEAN
  512. SetValue (
  513. IN PWSTRING Arg,
  514. IN CHNUM chnIdx,
  515. IN CHNUM chnEnd,
  516. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  517. );
  518. protected:
  519. NONVIRTUAL
  520. VOID
  521. Construct (
  522. );
  523. BOOLEAN _fValueSet; // TRUE when value set
  524. PWSTRING _Lexeme; // Matched Lexeme
  525. DSTRING _Pattern; // Pattern
  526. };
  527. #endif // _ARGUMENT
  528. /*++
  529. Copyright (c) 1990 Microsoft Corporation
  530. Module Name:
  531. FLAG_ARGUMENT
  532. Abstract:
  533. Argument class for flags and switches.
  534. Author:
  535. steve rowe stever 2/1/91
  536. Revision History:
  537. --*/
  538. #if !defined ( _FLAG_ARGUMENT_ )
  539. #define _FLAG_ARGUMENT_
  540. DECLARE_CLASS( FLAG_ARGUMENT );
  541. class FLAG_ARGUMENT : public ARGUMENT {
  542. public:
  543. ULIB_EXPORT
  544. DECLARE_CONSTRUCTOR( FLAG_ARGUMENT );
  545. NONVIRTUAL
  546. ULIB_EXPORT
  547. BOOLEAN
  548. Initialize (
  549. IN PSTR Pattern
  550. );
  551. NONVIRTUAL
  552. ULIB_EXPORT
  553. BOOLEAN
  554. Initialize (
  555. IN PWSTRING Pattern
  556. );
  557. VIRTUAL
  558. BOOLEAN
  559. SetValue (
  560. IN PWSTRING Arg,
  561. IN CHNUM chnIdx,
  562. IN CHNUM chnEnd,
  563. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  564. );
  565. NONVIRTUAL
  566. BOOLEAN
  567. QueryFlag (
  568. );
  569. NONVIRTUAL
  570. ULONG
  571. QueryArgPos(
  572. );
  573. private:
  574. NONVIRTUAL
  575. VOID
  576. Construct (
  577. );
  578. ULONG _LastConsumedCount; // Lexemes consumed
  579. BOOLEAN _flag; // TRUE if flag (switch) set
  580. };
  581. INLINE
  582. BOOLEAN
  583. FLAG_ARGUMENT::QueryFlag (
  584. )
  585. /*++
  586. Routine Description:
  587. Returns TRUE if flag set
  588. Arguments:
  589. none
  590. Return Value:
  591. TRUE if flag set. FALSE otherwise
  592. --*/
  593. {
  594. return _flag;
  595. }
  596. INLINE
  597. ULONG
  598. FLAG_ARGUMENT::QueryArgPos (
  599. )
  600. /*++
  601. Routine Description:
  602. Returns the last position of the argument on the command line.
  603. Arguments:
  604. none
  605. Return Value:
  606. The return value is only meaningful if IsValueSet() is TRUE.
  607. --*/
  608. {
  609. return _LastConsumedCount;
  610. }
  611. #endif // _FLAG_ARGUMENT_
  612. /*++
  613. Copyright (c) 1990 Microsoft Corporation
  614. Module Name:
  615. STRING_ARGUMENT
  616. Abstract:
  617. Argument class for strings.
  618. Author:
  619. steve rowe stever 2/1/91
  620. Revision History:
  621. --*/
  622. #if !defined ( _STRING_ARGUMENT_ )
  623. #define _STRING_ARGUMENT_
  624. DECLARE_CLASS( STRING_ARGUMENT );
  625. class STRING_ARGUMENT : public ARGUMENT {
  626. public:
  627. ULIB_EXPORT
  628. DECLARE_CONSTRUCTOR( STRING_ARGUMENT );
  629. NONVIRTUAL
  630. ULIB_EXPORT
  631. ~STRING_ARGUMENT(
  632. );
  633. NONVIRTUAL
  634. ULIB_EXPORT
  635. BOOLEAN
  636. Initialize (
  637. IN PSTR Pattern
  638. );
  639. NONVIRTUAL
  640. BOOLEAN
  641. Initialize (
  642. IN PWSTRING Pattern
  643. );
  644. NONVIRTUAL
  645. PWSTRING
  646. GetString (
  647. );
  648. VIRTUAL
  649. BOOLEAN
  650. SetValue (
  651. IN PWSTRING Arg,
  652. IN CHNUM chnIdx,
  653. IN CHNUM chnEnd,
  654. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  655. );
  656. protected:
  657. NONVIRTUAL
  658. VOID
  659. Construct (
  660. );
  661. PWSTRING _String; // Pointer to the string
  662. };
  663. INLINE
  664. PWSTRING
  665. STRING_ARGUMENT::GetString (
  666. )
  667. /*++
  668. Routine Description:
  669. Returns pointer to the string
  670. Arguments:
  671. none
  672. Return Value:
  673. pointer to the string
  674. --*/
  675. {
  676. DebugAssert( _fValueSet );
  677. return _String;
  678. }
  679. #endif // _STRING_ARGUMENT_
  680. /*++
  681. Copyright (c) 1990 Microsoft Corporation
  682. Module Name:
  683. LONG_ARGUMENT
  684. Abstract:
  685. Argument class for long integers.
  686. Author:
  687. steve rowe stever 2/1/91
  688. Revision History:
  689. --*/
  690. #if !defined ( _LONG_ARGUMENT_ )
  691. #define _LONG_ARGUMENT_
  692. DECLARE_CLASS( LONG_ARGUMENT );
  693. class LONG_ARGUMENT : public ARGUMENT {
  694. public:
  695. ULIB_EXPORT
  696. DECLARE_CONSTRUCTOR( LONG_ARGUMENT );
  697. NONVIRTUAL
  698. ULIB_EXPORT
  699. BOOLEAN
  700. Initialize (
  701. IN PSTR Pattern
  702. );
  703. NONVIRTUAL
  704. BOOLEAN
  705. Initialize (
  706. IN PWSTRING Pattern
  707. );
  708. VIRTUAL
  709. BOOLEAN
  710. SetValue (
  711. IN PWSTRING Arg,
  712. IN CHNUM chnIdx,
  713. IN CHNUM chnEnd,
  714. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  715. );
  716. NONVIRTUAL
  717. LONG
  718. QueryLong (
  719. );
  720. private:
  721. NONVIRTUAL
  722. VOID
  723. Construct (
  724. );
  725. LONG _value; // Long value
  726. };
  727. INLINE
  728. LONG
  729. LONG_ARGUMENT::QueryLong (
  730. )
  731. /*++
  732. Routine Description:
  733. Returns value of the long argument
  734. Arguments:
  735. none
  736. Return Value:
  737. value of the argument
  738. --*/
  739. {
  740. DebugAssert( _fValueSet );
  741. return _value;
  742. }
  743. #endif // _LONG_ARGUMENT_
  744. #if !defined( _AUTOCHECK_ )
  745. /*++
  746. Copyright (c) 1990 Microsoft Corporation
  747. Module Name:
  748. PATH_ARGUMENT
  749. Abstract:
  750. Argument class for paths.
  751. Author:
  752. steve rowe stever 2/1/91
  753. Revision History:
  754. --*/
  755. #if !defined( _PATH_ARGUMENT_ )
  756. #define _PATH_ARGUMENT_
  757. DECLARE_CLASS( PATH_ARGUMENT );
  758. class PATH_ARGUMENT : public ARGUMENT {
  759. public:
  760. ULIB_EXPORT
  761. DECLARE_CONSTRUCTOR( PATH_ARGUMENT );
  762. ULIB_EXPORT
  763. NONVIRTUAL
  764. ~PATH_ARGUMENT (
  765. );
  766. NONVIRTUAL
  767. ULIB_EXPORT
  768. BOOLEAN
  769. Initialize (
  770. IN PSTR Pattern,
  771. IN BOOLEAN Canonicalize DEFAULT FALSE
  772. );
  773. NONVIRTUAL
  774. BOOLEAN
  775. Initialize (
  776. IN PWSTRING Pattern,
  777. IN BOOLEAN Canonicalize DEFAULT FALSE
  778. );
  779. NONVIRTUAL
  780. PPATH
  781. GetPath (
  782. );
  783. VIRTUAL
  784. BOOLEAN
  785. SetValue (
  786. IN PWSTRING Arg,
  787. IN CHNUM chnIdx,
  788. IN CHNUM chnEnd,
  789. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  790. );
  791. protected:
  792. NONVIRTUAL
  793. VOID
  794. Construct (
  795. );
  796. PPATH _Path; // Pointer to the path
  797. BOOLEAN _Canonicalize; // Canonicalization flag
  798. private:
  799. NONVIRTUAL
  800. VOID
  801. Destroy (
  802. );
  803. };
  804. INLINE
  805. PPATH
  806. PATH_ARGUMENT::GetPath (
  807. )
  808. /*++
  809. Routine Description:
  810. Returns pointer to the path
  811. Arguments:
  812. none
  813. Return Value:
  814. pointer to the path
  815. --*/
  816. {
  817. DebugAssert( _fValueSet );
  818. return _Path;
  819. }
  820. #endif // _PATH_ARGUMENT_
  821. #endif // _AUTOCHECK_
  822. #if !defined( _AUTOCHECK_ )
  823. /*++
  824. Copyright (c) 1990 Microsoft Corporation
  825. Module Name:
  826. MULTIPLE_PATH_ARGUMENT
  827. Abstract:
  828. Provide for access to command line arguments that are file or path names.
  829. Author:
  830. steve rowe stever 2/1/91
  831. Environment:
  832. user
  833. Revision History:
  834. --*/
  835. /*++
  836. Copyright (c) 1990 Microsoft Corporation
  837. Module Name:
  838. MULTIPLE_PATH_ARGUMENT
  839. Abstract:
  840. Hold multiple file names on command line.
  841. Author:
  842. steve rowe stever 2/1/91
  843. Revision History:
  844. --*/
  845. #if !defined ( _MULTIPLE_PATH_ARGUMENT_ )
  846. #define _MULTIPLE_PATH_ARGUMENT_
  847. DECLARE_CLASS( MULTIPLE_PATH_ARGUMENT );
  848. class MULTIPLE_PATH_ARGUMENT : public PATH_ARGUMENT {
  849. public:
  850. ULIB_EXPORT
  851. DECLARE_CONSTRUCTOR( MULTIPLE_PATH_ARGUMENT );
  852. NONVIRTUAL
  853. ULIB_EXPORT
  854. ~MULTIPLE_PATH_ARGUMENT (
  855. );
  856. NONVIRTUAL
  857. ULIB_EXPORT
  858. BOOLEAN
  859. Initialize (
  860. IN PSTR Pattern,
  861. IN BOOLEAN Canonicalize DEFAULT FALSE,
  862. IN BOOLEAN ExpandWildCards DEFAULT FALSE
  863. );
  864. NONVIRTUAL
  865. BOOLEAN
  866. Initialize (
  867. IN PWSTRING Pattern,
  868. IN BOOLEAN Canonicalize DEFAULT FALSE,
  869. IN BOOLEAN ExpandWildCards DEFAULT FALSE
  870. );
  871. NONVIRTUAL
  872. PCWSTRING
  873. GetLexemeThatFailed (
  874. );
  875. NONVIRTUAL
  876. PARRAY
  877. GetPathArray (
  878. );
  879. NONVIRTUAL
  880. ULONG
  881. QueryPathCount (
  882. );
  883. VIRTUAL
  884. BOOLEAN
  885. SetValue (
  886. IN PWSTRING pwcArg,
  887. IN CHNUM chnIdx,
  888. IN CHNUM chnEnd,
  889. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  890. );
  891. NONVIRTUAL
  892. BOOLEAN
  893. WildCardExpansionFailed (
  894. );
  895. private:
  896. NONVIRTUAL
  897. VOID
  898. Construct (
  899. );
  900. NONVIRTUAL
  901. VOID
  902. Destroy (
  903. );
  904. PARRAY _PathArray;
  905. ULONG _PathCount;
  906. BOOLEAN _ExpandWildCards;
  907. BOOLEAN _WildCardExpansionFailed;
  908. DSTRING _LexemeThatFailed;
  909. };
  910. INLINE
  911. PCWSTRING
  912. MULTIPLE_PATH_ARGUMENT::GetLexemeThatFailed (
  913. )
  914. /*++
  915. Routine Description:
  916. Gets the lexeme that failed in case of a wildcard expansion failure
  917. Arguments:
  918. none
  919. Return Value:
  920. Pointer to the lexeme that failed
  921. --*/
  922. {
  923. return _WildCardExpansionFailed ? (PCWSTRING)&_LexemeThatFailed : NULL;
  924. }
  925. INLINE
  926. PARRAY
  927. MULTIPLE_PATH_ARGUMENT::GetPathArray (
  928. )
  929. /*++
  930. Routine Description:
  931. Returns pointer to the path array
  932. Arguments:
  933. none
  934. Return Value:
  935. pointer to the path array
  936. --*/
  937. {
  938. return _PathArray;
  939. }
  940. INLINE
  941. ULONG
  942. MULTIPLE_PATH_ARGUMENT::QueryPathCount (
  943. )
  944. /*++
  945. Routine Description:
  946. Returns number of paths in the array
  947. Arguments:
  948. none
  949. Return Value:
  950. Number of paths in the array
  951. --*/
  952. {
  953. return _PathCount;
  954. }
  955. INLINE
  956. BOOLEAN
  957. MULTIPLE_PATH_ARGUMENT::WildCardExpansionFailed (
  958. )
  959. /*++
  960. Routine Description:
  961. Tells the caller if wildcard expansion failed
  962. Arguments:
  963. none
  964. Return Value:
  965. BOOLEAN - TRUE if wildcard expansion failed
  966. --*/
  967. {
  968. return _WildCardExpansionFailed;
  969. }
  970. #endif // _MULTIPLE_PATH_ARGUMENT_
  971. #endif // _AUTOCHECK_
  972. #if !defined( _AUTOCHECK_ )
  973. /*++
  974. Copyright (c) 1990 Microsoft Corporation
  975. Module Name:
  976. TIMEINFO_ARGUMENT
  977. Abstract:
  978. Argument class for time information.
  979. Author:
  980. Ramon Juan San Andres (ramonsa) May-15-1991
  981. Revision History:
  982. --*/
  983. #if !defined ( _TIMEINFO_ARGUMENT_ )
  984. #define _TIMEINFO_ARGUMENT_
  985. DECLARE_CLASS( TIMEINFO_ARGUMENT );
  986. class TIMEINFO_ARGUMENT : public ARGUMENT {
  987. public:
  988. ULIB_EXPORT
  989. DECLARE_CONSTRUCTOR( TIMEINFO_ARGUMENT );
  990. NONVIRTUAL
  991. ULIB_EXPORT
  992. ~TIMEINFO_ARGUMENT(
  993. );
  994. NONVIRTUAL
  995. ULIB_EXPORT
  996. BOOLEAN
  997. Initialize (
  998. IN PSTR Pattern
  999. );
  1000. NONVIRTUAL
  1001. BOOLEAN
  1002. Initialize (
  1003. IN PWSTRING Pattern
  1004. );
  1005. VIRTUAL
  1006. BOOLEAN
  1007. SetValue (
  1008. IN PWSTRING Arg,
  1009. IN CHNUM chnIdx,
  1010. IN CHNUM chnEnd,
  1011. IN PARGUMENT_LEXEMIZER ArgumentLexemizer
  1012. );
  1013. NONVIRTUAL
  1014. PTIMEINFO
  1015. GetTimeInfo (
  1016. );
  1017. private:
  1018. NONVIRTUAL
  1019. VOID
  1020. Construct (
  1021. );
  1022. PTIMEINFO _TimeInfo; // Time info.
  1023. };
  1024. INLINE
  1025. PTIMEINFO
  1026. TIMEINFO_ARGUMENT::GetTimeInfo (
  1027. )
  1028. /*++
  1029. Routine Description:
  1030. Returns pointer to the time information
  1031. Arguments:
  1032. none
  1033. Return Value:
  1034. Pointer to time info.
  1035. --*/
  1036. {
  1037. DebugAssert( _fValueSet );
  1038. return _TimeInfo;
  1039. }
  1040. #endif // _TIMEINFO_ARGUMENT_
  1041. #endif // _AUTOCHECK_
  1042. #if !defined( _AUTOCHECK_ )
  1043. /*++
  1044. Copyright (c) 1990 Microsoft Corporation
  1045. Module Name:
  1046. TIMEINFO_ARGUMENT
  1047. Abstract:
  1048. Argument class for time information.
  1049. Author:
  1050. Ramon Juan San Andres (ramonsa) May-15-1991
  1051. Revision History:
  1052. --*/
  1053. #if !defined ( _REST_OF_LINE_ARGUMENT_ )
  1054. #define _REST_OF_LINE_ARGUMENT_
  1055. DECLARE_CLASS( REST_OF_LINE_ARGUMENT );
  1056. class REST_OF_LINE_ARGUMENT : public ARGUMENT {
  1057. public:
  1058. ULIB_EXPORT
  1059. DECLARE_CONSTRUCTOR( REST_OF_LINE_ARGUMENT );
  1060. NONVIRTUAL
  1061. ULIB_EXPORT
  1062. BOOLEAN
  1063. Initialize(
  1064. );
  1065. VIRTUAL
  1066. BOOLEAN
  1067. SetIfMatch(
  1068. IN OUT PARGUMENT_LEXEMIZER ArgumentLexemizer,
  1069. IN BOOLEAN CaseSensitive
  1070. );
  1071. NONVIRTUAL
  1072. PCWSTRING
  1073. GetRestOfLine(
  1074. ) CONST;
  1075. private:
  1076. DSTRING _RestOfLine;
  1077. };
  1078. INLINE
  1079. PCWSTRING
  1080. REST_OF_LINE_ARGUMENT::GetRestOfLine(
  1081. ) CONST
  1082. /*++
  1083. Routine Description:
  1084. Returns pointer to the macro argument.
  1085. Arguments:
  1086. none
  1087. Return Value:
  1088. A pointer to the macro argument.
  1089. --*/
  1090. {
  1091. DebugAssert( _fValueSet );
  1092. return &_RestOfLine;
  1093. }
  1094. #endif // _REST_OF_LINE_ARGUMENT_
  1095. #endif // _AUTOCHECK_