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

Last change on this file since 5476 was 5476, checked in by cameron, 2 years ago

Command line interface - systematic support for legacy flags

File size: 2.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/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
39   
40/*
41 *  B.  Grep input sources and interpretation.
42 */
43   
44   
45// Grep input source control corresponding to -r, -R flags.
46extern bool RecursiveFlag; // -r
47extern bool DereferenceRecursiveFlag; // -R
48extern bool TextFlag; // -a
49extern bool BinaryFlag; // -U
50extern bool NullDataFlag; // -z
51extern bool MmapFlag; // -mmap
52   
53/*
54 *  C.  Grep output modes and options.
55 */
56
57//
58//  Grep abbreviated output modes corresponding to -q, -l, -L, -c flags, or normal
59//  matched line output mode (no abbreviated mode flag specified).
60//
61enum GrepModeType {QuietMode, FilesWithMatch, FilesWithoutMatch, CountOnly, NormalMode};
62extern GrepModeType Mode;
63
64enum ColoringType {alwaysColor, autoColor, neverColor};
65extern ColoringType ColorFlag;
66   
67extern bool NoMessagesFlag; // -s
68extern bool WithFilenameFlag; // -H
69extern bool NoFilenameFlag; // -h
70extern bool NullFlag; // -Z
71extern bool LineNumberFlag; // -n
72extern bool ByteOffsetFlag; // -b
73extern bool UnixByteOffsetsFlag; // -u
74extern bool InitialTabFlag; // -T
75extern bool OnlyMatchingFlag; // -o
76extern bool LineBufferedFlag; // -line-buffered
77extern bool NormalizeLineBreaksFlag; // -normalize-line-breaks
78extern size_t AfterContextFlag; // -A
79extern size_t BeforeContextFlag; // -B
80extern size_t ContextFlag; // -C
81extern size_t MaxCountFlag; // -m
82   
83
84//
85// icgrep exit codes are consistent with POSIX specifications.
86enum ExitCode {
87    MatchFoundExitCode = 0,       // At least one match was found.
88    MatchNotFoundExitCode = 1,    // No matches were found.
89    InternalFailureCode = 2,      // Fatal error code due to program logic or system problem.
90    UsageErrorCode = 3            // Use of unsupported regexp syntax or error in command line parameters.
91};
92
93}
94
95#endif
Note: See TracBrowser for help on using the repository browser.