8 typedef int pcre_extra;
11 #include "thread-utils.h"
30 enum grep_header_field {
31 GREP_HEADER_AUTHOR = 0,
34 #define GREP_HEADER_FIELD_MAX (GREP_HEADER_COMMITTER + 1)
37 struct grep_pat *next;
40 enum grep_pat_token token;
43 enum grep_header_field field;
46 pcre_extra *pcre_extra_info;
49 unsigned ignore_case:1;
50 unsigned word_regexp:1;
62 enum grep_expr_node node;
65 struct grep_pat *atom;
66 struct grep_expr *unary;
68 struct grep_expr *left;
69 struct grep_expr *right;
75 struct grep_pat *pattern_list;
76 struct grep_pat **pattern_tail;
77 struct grep_pat *header_list;
78 struct grep_pat **header_tail;
79 struct grep_expr *pattern_expression;
88 int unmatch_name_only;
93 #define GREP_BINARY_DEFAULT 0
94 #define GREP_BINARY_NOMATCH 1
95 #define GREP_BINARY_TEXT 2
101 int null_following_name;
106 char color_context[COLOR_MAXLEN];
107 char color_filename[COLOR_MAXLEN];
108 char color_function[COLOR_MAXLEN];
109 char color_lineno[COLOR_MAXLEN];
110 char color_match[COLOR_MAXLEN];
111 char color_selected[COLOR_MAXLEN];
112 char color_sep[COLOR_MAXLEN];
114 unsigned pre_context;
115 unsigned post_context;
122 void (*output)(struct grep_opt *opt, const void *data, size_t size);
126 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);
127 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
128 extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
129 extern void compile_grep_patterns(struct grep_opt *opt);
130 extern void free_grep_patterns(struct grep_opt *opt);
131 extern int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size);
136 enum grep_source_type {
146 struct userdiff_driver *driver;
149 void grep_source_init(struct grep_source *gs, enum grep_source_type type,
150 const char *name, const void *identifier);
151 int grep_source_load(struct grep_source *gs);
152 void grep_source_clear_data(struct grep_source *gs);
153 void grep_source_clear(struct grep_source *gs);
154 void grep_source_load_driver(struct grep_source *gs);
155 int grep_source_is_binary(struct grep_source *gs);
157 int grep_source(struct grep_opt *opt, struct grep_source *gs);
159 extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
160 extern int grep_threads_ok(const struct grep_opt *opt);
164 * Mutex used around access to the attributes machinery if
165 * opt->use_threads. Must be initialized/destroyed by callers!
167 extern int grep_use_locks;
168 extern pthread_mutex_t grep_attr_mutex;
169 extern pthread_mutex_t grep_read_mutex;
171 static inline void grep_read_lock(void)
174 pthread_mutex_lock(&grep_read_mutex);
177 static inline void grep_read_unlock(void)
180 pthread_mutex_unlock(&grep_read_mutex);
184 #define grep_read_lock()
185 #define grep_read_unlock()