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

Last change on this file since 5732 was 5705, checked in by cameron, 19 months ago

Drop linebreak normalization; add1 attribute for grep kernel; pablo indexed advance initial check-in

File size: 3.2 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 MmapFlag; // -mmap
53extern std::string ExcludeFlag; // -exclude
54extern std::string ExcludeFromFlag; // -exclude-from
55extern std::string ExcludeDirFlag; // -exclude-dir
56extern std::string IncludeFlag; // -include
57
58/*
59 *  C.  Grep output modes and options.
60 */
61
62//
63//  Grep abbreviated output modes corresponding to -q, -l, -L, -c flags, or normal
64//  matched line output mode (no abbreviated mode flag specified).
65//
66enum GrepModeType {QuietMode, FilesWithMatch, FilesWithoutMatch, CountOnly, NormalMode};
67extern GrepModeType Mode;
68
69enum ColoringType {alwaysColor, autoColor, neverColor};
70extern ColoringType ColorFlag;
71
72enum DevDirAction {Read, Skip, Recurse};
73extern DevDirAction DevicesFlag;
74extern DevDirAction DirectoriesFlag;
75   
76enum BinaryFilesMode {Binary, WithoutMatch, Text};
77extern BinaryFilesMode BinaryFilesFlag;
78   
79extern bool NoMessagesFlag; // -s  (also set by QuietMode/-q)
80extern bool WithFilenameFlag; // -H
81extern bool NoFilenameFlag; // -h
82extern bool NullFlag; // -Z
83extern bool LineNumberFlag; // -n
84extern bool ByteOffsetFlag; // -b
85extern bool UnixByteOffsetsFlag; // -u
86extern bool InitialTabFlag; // -T
87extern bool OnlyMatchingFlag; // -o
88extern std::string LabelFlag; // -label
89extern bool LineBufferedFlag; // -line-buffered
90extern int AfterContextFlag; // -A
91extern int BeforeContextFlag; // -B
92extern int ContextFlag; // -C
93extern int MaxCountFlag; // -m  (overridden and set to 1 with -q, -l, -L modes)
94   
95
96//
97// icgrep exit codes are consistent with POSIX specifications.
98enum ExitCode {
99    MatchFoundExitCode = 0,       // At least one match was found.
100    MatchNotFoundExitCode = 1,    // No matches were found.
101    InternalFailureCode = 2,      // Fatal error code due to program logic or system problem.
102    UsageErrorCode = 3            // Use of unsupported regexp syntax or error in command line parameters.
103};
104
105}
106
107#endif
Note: See TracBrowser for help on using the repository browser.