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

Last change on this file since 6155 was 5999, checked in by cameron, 15 months ago

Handling of file system errors

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