Documentation: Transplanting branch with git-rebase --onto
[git/jnareb-git/bp-gitweb.git] / grep.h
blobaf9098cfe8699680aeaa11790dad3e8d556ed395
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 struct grep_pat {
21 struct grep_pat *next;
22 const char *origin;
23 int no;
24 enum grep_pat_token token;
25 const char *pattern;
26 regex_t regexp;
29 enum grep_expr_node {
30 GREP_NODE_ATOM,
31 GREP_NODE_NOT,
32 GREP_NODE_AND,
33 GREP_NODE_OR,
36 struct grep_expr {
37 enum grep_expr_node node;
38 union {
39 struct grep_pat *atom;
40 struct grep_expr *unary;
41 struct {
42 struct grep_expr *left;
43 struct grep_expr *right;
44 } binary;
45 } u;
48 struct grep_opt {
49 struct grep_pat *pattern_list;
50 struct grep_pat **pattern_tail;
51 struct grep_expr *pattern_expression;
52 int prefix_length;
53 regex_t regexp;
54 unsigned linenum:1;
55 unsigned invert:1;
56 unsigned status_only:1;
57 unsigned name_only:1;
58 unsigned unmatch_name_only:1;
59 unsigned count:1;
60 unsigned word_regexp:1;
61 unsigned fixed:1;
62 #define GREP_BINARY_DEFAULT 0
63 #define GREP_BINARY_NOMATCH 1
64 #define GREP_BINARY_TEXT 2
65 unsigned binary:2;
66 unsigned extended:1;
67 unsigned relative:1;
68 unsigned pathname:1;
69 int regflags;
70 unsigned pre_context;
71 unsigned post_context;
74 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
75 extern void compile_grep_patterns(struct grep_opt *opt);
76 extern void free_grep_patterns(struct grep_opt *opt);
77 extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
79 #endif