Merge branch 'rc/maint-http-no-head-pack-check' into maint
[git/jnareb-git/bp-gitweb.git] / grep.h
blob5581363c4ddb988830f9c9b776b057821107f92a
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 enum grep_header_field field;
33 regex_t regexp;
34 unsigned fixed:1;
35 unsigned word_regexp:1;
38 enum grep_expr_node {
39 GREP_NODE_ATOM,
40 GREP_NODE_NOT,
41 GREP_NODE_AND,
42 GREP_NODE_OR,
45 struct grep_expr {
46 enum grep_expr_node node;
47 unsigned hit;
48 union {
49 struct grep_pat *atom;
50 struct grep_expr *unary;
51 struct {
52 struct grep_expr *left;
53 struct grep_expr *right;
54 } binary;
55 } u;
58 struct grep_opt {
59 struct grep_pat *pattern_list;
60 struct grep_pat **pattern_tail;
61 struct grep_expr *pattern_expression;
62 const char *prefix;
63 int prefix_length;
64 regex_t regexp;
65 int linenum;
66 int invert;
67 int status_only;
68 int name_only;
69 int unmatch_name_only;
70 int count;
71 int word_regexp;
72 int fixed;
73 int all_match;
74 #define GREP_BINARY_DEFAULT 0
75 #define GREP_BINARY_NOMATCH 1
76 #define GREP_BINARY_TEXT 2
77 int binary;
78 int extended;
79 int relative;
80 int pathname;
81 int null_following_name;
82 int color;
83 int funcname;
84 char color_match[COLOR_MAXLEN];
85 const char *color_external;
86 int regflags;
87 unsigned pre_context;
88 unsigned post_context;
89 unsigned last_shown;
90 int show_hunk_mark;
91 void *priv;
94 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
95 extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
96 extern void compile_grep_patterns(struct grep_opt *opt);
97 extern void free_grep_patterns(struct grep_opt *opt);
98 extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
100 #endif