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

Last change on this file since 5940 was 5940, checked in by cameron, 12 months ago

icgrep -GLOB option for GLOB syntax, utilities for file include/exclude command arguments

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