t2016 (checkout -p): add missing &&
[git/jnareb-git/bp-gitweb.git] / grep.h
blobefa8cff980af2b2c06dad080876637d16b5c4985
1 #ifndef GREP_H
2 #define GREP_H
3 #include "color.h"
5 enum grep_pat_token {
6 GREP_PATTERN,
7 GREP_PATTERN_HEAD,
8 GREP_PATTERN_BODY,
9 GREP_AND,
10 GREP_OPEN_PAREN,
11 GREP_CLOSE_PAREN,
12 GREP_NOT,
13 GREP_OR
16 enum grep_context {
17 GREP_CONTEXT_HEAD,
18 GREP_CONTEXT_BODY
21 enum grep_header_field {
22 GREP_HEADER_AUTHOR = 0,
23 GREP_HEADER_COMMITTER
26 struct grep_pat {
27 struct grep_pat *next;
28 const char *origin;
29 int no;
30 enum grep_pat_token token;
31 const char *pattern;
32 size_t patternlen;
33 enum grep_header_field field;
34 regex_t regexp;
35 unsigned fixed:1;
36 unsigned ignore_case:1;
37 unsigned word_regexp:1;
40 enum grep_expr_node {
41 GREP_NODE_ATOM,
42 GREP_NODE_NOT,
43 GREP_NODE_AND,
44 GREP_NODE_OR
47 struct grep_expr {
48 enum grep_expr_node node;
49 unsigned hit;
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;
60 struct grep_opt {
61 struct grep_pat *pattern_list;
62 struct grep_pat **pattern_tail;
63 struct grep_pat *header_list;
64 struct grep_pat **header_tail;
65 struct grep_expr *pattern_expression;
66 const char *prefix;
67 int prefix_length;
68 regex_t regexp;
69 int linenum;
70 int invert;
71 int ignore_case;
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;
79 #define GREP_BINARY_DEFAULT 0
80 #define GREP_BINARY_NOMATCH 1
81 #define GREP_BINARY_TEXT 2
82 int binary;
83 int extended;
84 int relative;
85 int pathname;
86 int null_following_name;
87 int color;
88 int max_depth;
89 int funcname;
90 char color_context[COLOR_MAXLEN];
91 char color_filename[COLOR_MAXLEN];
92 char color_function[COLOR_MAXLEN];
93 char color_lineno[COLOR_MAXLEN];
94 char color_match[COLOR_MAXLEN];
95 char color_selected[COLOR_MAXLEN];
96 char color_sep[COLOR_MAXLEN];
97 int regflags;
98 unsigned pre_context;
99 unsigned post_context;
100 unsigned last_shown;
101 int show_hunk_mark;
102 void *priv;
104 void (*output)(struct grep_opt *opt, const void *data, size_t size);
105 void *output_priv;
108 extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);
109 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
110 extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
111 extern void compile_grep_patterns(struct grep_opt *opt);
112 extern void free_grep_patterns(struct grep_opt *opt);
113 extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
115 extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
116 extern int grep_threads_ok(const struct grep_opt *opt);
118 #endif