1 // ArchiveCommandLine.h
2 
3 #ifndef ZIP7_INC_ARCHIVE_COMMAND_LINE_H
4 #define ZIP7_INC_ARCHIVE_COMMAND_LINE_H
5 
6 #include "../../../Common/CommandLineParser.h"
7 #include "../../../Common/Wildcard.h"
8 
9 #include "EnumDirItems.h"
10 
11 #include "Extract.h"
12 #include "HashCalc.h"
13 #include "Update.h"
14 
15 typedef CMessagePathException CArcCmdLineException;
16 
17 namespace NCommandType { enum EEnum
18 {
19   kAdd = 0,
20   kUpdate,
21   kDelete,
22   kTest,
23   kExtract,
24   kExtractFull,
25   kList,
26   kBenchmark,
27   kInfo,
28   kHash,
29   kRename
30 };}
31 
32 struct CArcCommand
33 {
34   NCommandType::EEnum CommandType;
35 
36   bool IsFromExtractGroup() const;
37   bool IsFromUpdateGroup() const;
IsTestCommandCArcCommand38   bool IsTestCommand() const { return CommandType == NCommandType::kTest; }
39   NExtract::NPathMode::EEnum GetPathMode() const;
40 };
41 
42 enum
43 {
44   k_OutStream_disabled = 0,
45   k_OutStream_stdout = 1,
46   k_OutStream_stderr = 2
47 };
48 
49 struct CArcCmdLineOptions
50 {
51   bool HelpMode;
52 
53   // bool LargePages;
54   bool CaseSensitive_Change;
55   bool CaseSensitive;
56 
57   bool IsInTerminal;
58   bool IsStdOutTerminal;
59   bool IsStdErrTerminal;
60   bool StdInMode;
61   bool StdOutMode;
62   bool EnableHeaders;
63 
64   bool YesToAll;
65   bool ShowDialog;
66   bool TechMode;
67   bool ShowTime;
68 
69   CBoolPair NtSecurity;
70   CBoolPair AltStreams;
71   CBoolPair HardLinks;
72   CBoolPair SymLinks;
73 
74   CBoolPair StoreOwnerId;
75   CBoolPair StoreOwnerName;
76 
77   AString ListFields;
78 
79   int ConsoleCodePage;
80 
81   NWildcard::CCensor Censor;
82 
83   CArcCommand Command;
84   UString ArchiveName;
85 
86   #ifndef Z7_NO_CRYPTO
87   bool PasswordEnabled;
88   UString Password;
89   #endif
90 
91   UStringVector HashMethods;
92   // UString HashFilePath;
93 
94   // bool AppendName;
95   // UStringVector ArchivePathsSorted;
96   // UStringVector ArchivePathsFullSorted;
97   NWildcard::CCensor arcCensor;
98   UString ArcName_for_StdInMode;
99 
100   CObjectVector<CProperty> Properties;
101 
102   CExtractOptionsBase ExtractOptions;
103 
104   CUpdateOptions UpdateOptions;
105   CHashOptions HashOptions;
106   UString ArcType;
107   UStringVector ExcludedArcTypes;
108 
109   unsigned Number_for_Out;
110   unsigned Number_for_Errors;
111   unsigned Number_for_Percents;
112   unsigned LogLevel;
113 
114   // bool IsOutAllowed() const { return Number_for_Out != k_OutStream_disabled; }
115 
116   // Benchmark
117   UInt32 NumIterations;
118   bool NumIterations_Defined;
119 
CArcCmdLineOptionsCArcCmdLineOptions120   CArcCmdLineOptions():
121       HelpMode(false),
122       // LargePages(false),
123       CaseSensitive_Change(false),
124       CaseSensitive(false),
125 
126       IsInTerminal(false),
127       IsStdOutTerminal(false),
128       IsStdErrTerminal(false),
129 
130       StdInMode(false),
131       StdOutMode(false),
132 
133       EnableHeaders(false),
134 
135       YesToAll(false),
136       ShowDialog(false),
137       TechMode(false),
138       ShowTime(false),
139 
140       ConsoleCodePage(-1),
141 
142       Number_for_Out(k_OutStream_stdout),
143       Number_for_Errors(k_OutStream_stderr),
144       Number_for_Percents(k_OutStream_stdout),
145 
146       LogLevel(0)
147   {
148   }
149 };
150 
151 class CArcCmdLineParser
152 {
153   NCommandLineParser::CParser parser;
154 public:
155   UString Parse1Log;
156   void Parse1(const UStringVector &commandStrings, CArcCmdLineOptions &options);
157   void Parse2(CArcCmdLineOptions &options);
158 };
159 
160 #endif
161