grep: add pmatch and eflags arguments to match_one_pattern()
[git/gitweb.git] / grep.h
blobd2a8674be27a7ff22aca2913d5a2431e31cdf84f
1 #ifndef GREP_H
2 #define GREP_H
4 enum grep_pat_token {
5 GREP_PATTERN,
6 GREP_PATTERN_HEAD,
7 GREP_PATTERN_BODY,
8 GREP_AND,
9 GREP_OPEN_PAREN,
10 GREP_CLOSE_PAREN,
11 GREP_NOT,
12 GREP_OR,
15 enum grep_context {
16 GREP_CONTEXT_HEAD,
17 GREP_CONTEXT_BODY,
20 enum grep_header_field {
21 GREP_HEADER_AUTHOR = 0,
22 GREP_HEADER_COMMITTER,
25 struct grep_pat {
26 struct grep_pat *next;
27 const char *origin;
28 int no;
29 enum grep_pat_token token;
30 const char *pattern;
31 enum grep_header_field field;
32 regex_t regexp;
33 unsigned fixed:1;
34 unsigned word_regexp:1;
37 enum grep_expr_node {
38 GREP_NODE_ATOM,
39 GREP_NODE_NOT,
40 GREP_NODE_AND,
41 GREP_NODE_OR,
44 struct grep_expr {
45 enum grep_expr_node node;
46 unsigned hit;
47 union {
48 struct grep_pat *atom;
49 struct grep_expr *unary;
50 struct {
51 struct grep_expr *left;
52 struct grep_expr *right;
53 } binary;
54 } u;
57 struct grep_opt {
58 struct grep_pat *pattern_list;
59 struct grep_pat **pattern_tail;
60 struct grep_expr *pattern_expression;
61 int prefix_length;
62 regex_t regexp;
63 unsigned linenum:1;
64 unsigned invert:1;
65 unsigned status_only:1;
66 unsigned name_only:1;
67 unsigned unmatch_name_only:1;
68 unsigned count:1;
69 unsigned word_regexp:1;
70 unsigned fixed:1;
71 unsigned all_match:1;
72 #define GREP_BINARY_DEFAULT 0
73 #define GREP_BINARY_NOMATCH 1
74 #define GREP_BINARY_TEXT 2
75 unsigned binary:2;
76 unsigned extended:1;
77 unsigned relative:1;
78 unsigned pathname:1;
79 unsigned null_following_name:1;
80 int regflags;
81 unsigned pre_context;
82 unsigned post_context;
85 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
86 extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
87 extern void compile_grep_patterns(struct grep_opt *opt);
88 extern void free_grep_patterns(struct grep_opt *opt);
89 extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
91 #endif