grep.hon commit i18n: git-branch "remote branch '%s' not found" message (2852e1d)
   1#ifndef GREP_H
   2#define GREP_H
   3#include "color.h"
   4
   5enum 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
  14};
  15
  16enum grep_context {
  17        GREP_CONTEXT_HEAD,
  18        GREP_CONTEXT_BODY
  19};
  20
  21enum grep_header_field {
  22        GREP_HEADER_AUTHOR = 0,
  23        GREP_HEADER_COMMITTER
  24};
  25#define GREP_HEADER_FIELD_MAX (GREP_HEADER_COMMITTER + 1)
  26
  27struct grep_pat {
  28        struct grep_pat *next;
  29        const char *origin;
  30        int no;
  31        enum grep_pat_token token;
  32        const char *pattern;
  33        size_t patternlen;
  34        enum grep_header_field field;
  35        regex_t regexp;
  36        unsigned fixed:1;
  37        unsigned ignore_case:1;
  38        unsigned word_regexp:1;
  39};
  40
  41enum grep_expr_node {
  42        GREP_NODE_ATOM,
  43        GREP_NODE_NOT,
  44        GREP_NODE_AND,
  45        GREP_NODE_TRUE,
  46        GREP_NODE_OR
  47};
  48
  49struct grep_expr {
  50        enum grep_expr_node node;
  51        unsigned hit;
  52        union {
  53                struct grep_pat *atom;
  54                struct grep_expr *unary;
  55                struct {
  56                        struct grep_expr *left;
  57                        struct grep_expr *right;
  58                } binary;
  59        } u;
  60};
  61
  62struct grep_opt {
  63        struct grep_pat *pattern_list;
  64        struct grep_pat **pattern_tail;
  65        struct grep_pat *header_list;
  66        struct grep_pat **header_tail;
  67        struct grep_expr *pattern_expression;
  68        const char *prefix;
  69        int prefix_length;
  70        regex_t regexp;
  71        int linenum;
  72        int invert;
  73        int ignore_case;
  74        int status_only;
  75        int name_only;
  76        int unmatch_name_only;
  77        int count;
  78        int word_regexp;
  79        int fixed;
  80        int all_match;
  81#define GREP_BINARY_DEFAULT     0
  82#define GREP_BINARY_NOMATCH     1
  83#define GREP_BINARY_TEXT        2
  84        int binary;
  85        int extended;
  86        int relative;
  87        int pathname;
  88        int null_following_name;
  89        int color;
  90        int max_depth;
  91        int funcname;
  92        char color_context[COLOR_MAXLEN];
  93        char color_filename[COLOR_MAXLEN];
  94        char color_function[COLOR_MAXLEN];
  95        char color_lineno[COLOR_MAXLEN];
  96        char color_match[COLOR_MAXLEN];
  97        char color_selected[COLOR_MAXLEN];
  98        char color_sep[COLOR_MAXLEN];
  99        int regflags;
 100        unsigned pre_context;
 101        unsigned post_context;
 102        unsigned last_shown;
 103        int show_hunk_mark;
 104        void *priv;
 105
 106        void (*output)(struct grep_opt *opt, const void *data, size_t size);
 107        void *output_priv;
 108};
 109
 110extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);
 111extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
 112extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
 113extern void compile_grep_patterns(struct grep_opt *opt);
 114extern void free_grep_patterns(struct grep_opt *opt);
 115extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
 116
 117extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
 118extern int grep_threads_ok(const struct grep_opt *opt);
 119
 120#endif