]> git.ipfire.org Git - thirdparty/git.git/blame - grep.h
Makefile: Include subdirectories in "make cover" reports
[thirdparty/git.git] / grep.h
CommitLineData
83b5d2f5
JH
1#ifndef GREP_H
2#define GREP_H
7e8f59d5 3#include "color.h"
83b5d2f5
JH
4
5enum grep_pat_token {
6 GREP_PATTERN,
480c1ca6
JH
7 GREP_PATTERN_HEAD,
8 GREP_PATTERN_BODY,
83b5d2f5
JH
9 GREP_AND,
10 GREP_OPEN_PAREN,
11 GREP_CLOSE_PAREN,
12 GREP_NOT,
4b05548f 13 GREP_OR
83b5d2f5
JH
14};
15
480c1ca6
JH
16enum grep_context {
17 GREP_CONTEXT_HEAD,
4b05548f 18 GREP_CONTEXT_BODY
480c1ca6
JH
19};
20
a4d7d2c6
JH
21enum grep_header_field {
22 GREP_HEADER_AUTHOR = 0,
4b05548f 23 GREP_HEADER_COMMITTER
a4d7d2c6
JH
24};
25
83b5d2f5
JH
26struct grep_pat {
27 struct grep_pat *next;
28 const char *origin;
29 int no;
30 enum grep_pat_token token;
31 const char *pattern;
ed40a095 32 size_t patternlen;
a4d7d2c6 33 enum grep_header_field field;
83b5d2f5 34 regex_t regexp;
c822255c 35 unsigned fixed:1;
5183bf67 36 unsigned ignore_case:1;
d7eb527d 37 unsigned word_regexp:1;
83b5d2f5
JH
38};
39
40enum grep_expr_node {
41 GREP_NODE_ATOM,
42 GREP_NODE_NOT,
43 GREP_NODE_AND,
4b05548f 44 GREP_NODE_OR
83b5d2f5
JH
45};
46
47struct grep_expr {
48 enum grep_expr_node node;
0ab7befa 49 unsigned hit;
83b5d2f5
JH
50 union {
51 struct grep_pat *atom;
52 struct grep_expr *unary;
53 struct {
54 struct grep_expr *left;
55 struct grep_expr *right;
56 } binary;
57 } u;
58};
59
60struct grep_opt {
61 struct grep_pat *pattern_list;
62 struct grep_pat **pattern_tail;
80235ba7
JH
63 struct grep_pat *header_list;
64 struct grep_pat **header_tail;
83b5d2f5 65 struct grep_expr *pattern_expression;
493b7a08 66 const char *prefix;
83b5d2f5
JH
67 int prefix_length;
68 regex_t regexp;
3e230fa1
RS
69 int linenum;
70 int invert;
5183bf67 71 int ignore_case;
3e230fa1
RS
72 int status_only;
73 int name_only;
74 int unmatch_name_only;
75 int count;
76 int word_regexp;
77 int fixed;
78 int all_match;
83b5d2f5
JH
79#define GREP_BINARY_DEFAULT 0
80#define GREP_BINARY_NOMATCH 1
81#define GREP_BINARY_TEXT 2
3e230fa1
RS
82 int binary;
83 int extended;
84 int relative;
85 int pathname;
86 int null_following_name;
7e8f59d5 87 int color;
a91f453f 88 int max_depth;
2944e4e6 89 int funcname;
00588bb5 90 char color_context[COLOR_MAXLEN];
55f638bd 91 char color_filename[COLOR_MAXLEN];
00588bb5 92 char color_function[COLOR_MAXLEN];
55f638bd 93 char color_lineno[COLOR_MAXLEN];
7e8f59d5 94 char color_match[COLOR_MAXLEN];
00588bb5 95 char color_selected[COLOR_MAXLEN];
55f638bd 96 char color_sep[COLOR_MAXLEN];
83b5d2f5
JH
97 int regflags;
98 unsigned pre_context;
99 unsigned post_context;
5dd06d38 100 unsigned last_shown;
046802d0 101 int show_hunk_mark;
60ecac98 102 void *priv;
5b594f45
FK
103
104 void (*output)(struct grep_opt *opt, const void *data, size_t size);
105 void *output_priv;
83b5d2f5
JH
106};
107
ed40a095 108extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);
83b5d2f5 109extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
a4d7d2c6 110extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
83b5d2f5 111extern void compile_grep_patterns(struct grep_opt *opt);
b48fb5b6 112extern void free_grep_patterns(struct grep_opt *opt);
83b5d2f5
JH
113extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
114
5b594f45
FK
115extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
116extern int grep_threads_ok(const struct grep_opt *opt);
117
83b5d2f5 118#endif