source: icGREP/icgrep-devel/icgrep/grep_interface.h @ 5913

Last change on this file since 5913 was 5900, checked in by cameron, 17 months ago

Unicode-lines option; set default linebreak to LF

File size: 3.3 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 *
6 *  This file defines all the options, parameters and exit codes for icgrep as a
7 *  command line utility.
8 *
9 */
10#ifndef GREP_INTERFACE_H
11#define GREP_INTERFACE_H
12 
13#include <string>       // for string
14#include <vector>
15#include <re/re_parser.h>  // for re::RE_Syntax
16
17namespace re { class CC; }
18namespace re { class RE; }
19namespace llvm { namespace cl { class OptionCategory; } }
20
21
22namespace grep {
23   
24
25void InitializeCommandLineInterface(int argc, char *argv[]);
26   
27/*
28 *  A.  Regular expression syntax, interpretation and processing.
29 */
30 
31// The syntax specified with =E, -F, -G, or -PROSITE.
32extern re::RE_Syntax RegexpSyntax;
33   
34// Regular expression interpretation corresponding to -i, -v, -w, -x flags.
35extern bool IgnoreCaseFlag; // -i
36extern bool InvertMatchFlag; // -v
37extern bool LineRegexpFlag; // -x
38extern bool WordRegexpFlag; // -w
39extern std::vector<std::string> RegexpVector; // -e
40extern std::string FileFlag; // -f
41
42/*
43 *  B.  Grep input sources and interpretation.
44 */
45
46// Use DirectoriesFlag==Recurse to test for recursive mode.
47//extern bool RecursiveFlag;
48extern bool DereferenceRecursiveFlag; // -R
49extern bool TextFlag; // -a
50extern bool BinaryFlag; // -U
51extern bool NullDataFlag; // -z
52extern bool UnicodeLinesFlag; // -Unicode-lines
53
54extern bool MmapFlag; // -mmap
55
56extern std::string ExcludeFlag; // -exclude
57extern std::string ExcludeFromFlag; // -exclude-from
58extern std::string ExcludeDirFlag; // -exclude-dir
59extern std::string IncludeFlag; // -include
60
61/*
62 *  C.  Grep output modes and options.
63 */
64
65//
66//  Grep abbreviated output modes corresponding to -q, -l, -L, -c flags, or normal
67//  matched line output mode (no abbreviated mode flag specified).
68//
69enum GrepModeType {QuietMode, FilesWithMatch, FilesWithoutMatch, CountOnly, NormalMode};
70extern GrepModeType Mode;
71
72enum ColoringType {alwaysColor, autoColor, neverColor};
73extern ColoringType ColorFlag;
74
75enum DevDirAction {Read, Skip, Recurse};
76extern DevDirAction DevicesFlag;
77extern DevDirAction DirectoriesFlag;
78   
79enum BinaryFilesMode {Binary, WithoutMatch, Text};
80extern BinaryFilesMode BinaryFilesFlag;
81   
82extern bool NoMessagesFlag; // -s  (also set by QuietMode/-q)
83extern bool WithFilenameFlag; // -H
84extern bool NoFilenameFlag; // -h
85extern bool NullFlag; // -Z
86extern bool LineNumberFlag; // -n
87extern bool ByteOffsetFlag; // -b
88extern bool UnixByteOffsetsFlag; // -u
89extern bool InitialTabFlag; // -T
90extern bool OnlyMatchingFlag; // -o
91extern std::string LabelFlag; // -label
92extern bool LineBufferedFlag; // -line-buffered
93extern int AfterContextFlag; // -A
94extern int BeforeContextFlag; // -B
95extern int ContextFlag; // -C
96extern int MaxCountFlag; // -m  (overridden and set to 1 with -q, -l, -L modes)
97   
98
99//
100// icgrep exit codes are consistent with POSIX specifications.
101enum ExitCode {
102    MatchFoundExitCode = 0,       // At least one match was found.
103    MatchNotFoundExitCode = 1,    // No matches were found.
104    InternalFailureCode = 2,      // Fatal error code due to program logic or system problem.
105    UsageErrorCode = 3            // Use of unsupported regexp syntax or error in command line parameters.
106};
107
108}
109
110#endif
Note: See TracBrowser for help on using the repository browser.