grep.hon commit lstat_cache(): print a warning if doing ping-pong between cache types (7734f04)
   1#ifndef GREP_H
   2#define GREP_H
   3
   4enum 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,
  13};
  14
  15enum grep_context {
  16        GREP_CONTEXT_HEAD,
  17        GREP_CONTEXT_BODY,
  18};
  19
  20enum grep_header_field {
  21        GREP_HEADER_AUTHOR = 0,
  22        GREP_HEADER_COMMITTER,
  23};
  24
  25struct 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};
  35
  36enum grep_expr_node {
  37        GREP_NODE_ATOM,
  38        GREP_NODE_NOT,
  39        GREP_NODE_AND,
  40        GREP_NODE_OR,
  41};
  42
  43struct grep_expr {
  44        enum grep_expr_node node;
  45        unsigned hit;
  46        union {
  47                struct grep_pat *atom;
  48                struct grep_expr *unary;
  49                struct {
  50                        struct grep_expr *left;
  51                        struct grep_expr *right;
  52                } binary;
  53        } u;
  54};
  55
  56struct grep_opt {
  57        struct grep_pat *pattern_list;
  58        struct grep_pat **pattern_tail;
  59        struct grep_expr *pattern_expression;
  60        int prefix_length;
  61        regex_t regexp;
  62        unsigned linenum:1;
  63        unsigned invert:1;
  64        unsigned status_only:1;
  65        unsigned name_only:1;
  66        unsigned unmatch_name_only:1;
  67        unsigned count:1;
  68        unsigned word_regexp:1;
  69        unsigned fixed:1;
  70        unsigned all_match:1;
  71#define GREP_BINARY_DEFAULT     0
  72#define GREP_BINARY_NOMATCH     1
  73#define GREP_BINARY_TEXT        2
  74        unsigned binary:2;
  75        unsigned extended:1;
  76        unsigned relative:1;
  77        unsigned pathname:1;
  78        unsigned null_following_name:1;
  79        int regflags;
  80        unsigned pre_context;
  81        unsigned post_context;
  82};
  83
  84extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
  85extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
  86extern void compile_grep_patterns(struct grep_opt *opt);
  87extern void free_grep_patterns(struct grep_opt *opt);
  88extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
  89
  90#endif