8 typedef int pcre_extra
;
11 #include "thread-utils.h"
30 enum grep_header_field
{
31 GREP_HEADER_FIELD_MIN
= 0,
32 GREP_HEADER_AUTHOR
= GREP_HEADER_FIELD_MIN
,
33 GREP_HEADER_COMMITTER
,
36 /* Must be at the end of the enum */
41 struct grep_pat
*next
;
44 enum grep_pat_token token
;
47 enum grep_header_field field
;
50 pcre_extra
*pcre_extra_info
;
53 unsigned ignore_case
:1;
54 unsigned word_regexp
:1;
65 enum grep_pattern_type
{
66 GREP_PATTERN_TYPE_UNSPECIFIED
= 0,
67 GREP_PATTERN_TYPE_BRE
,
68 GREP_PATTERN_TYPE_ERE
,
69 GREP_PATTERN_TYPE_FIXED
,
70 GREP_PATTERN_TYPE_PCRE
74 enum grep_expr_node node
;
77 struct grep_pat
*atom
;
78 struct grep_expr
*unary
;
80 struct grep_expr
*left
;
81 struct grep_expr
*right
;
87 struct grep_pat
*pattern_list
;
88 struct grep_pat
**pattern_tail
;
89 struct grep_pat
*header_list
;
90 struct grep_pat
**header_tail
;
91 struct grep_expr
*pattern_expression
;
100 int unmatch_name_only
;
106 #define GREP_BINARY_DEFAULT 0
107 #define GREP_BINARY_NOMATCH 1
108 #define GREP_BINARY_TEXT 2
112 int use_reflog_filter
;
116 int null_following_name
;
121 int extended_regexp_option
;
122 int pattern_type_option
;
123 char color_context
[COLOR_MAXLEN
];
124 char color_filename
[COLOR_MAXLEN
];
125 char color_function
[COLOR_MAXLEN
];
126 char color_lineno
[COLOR_MAXLEN
];
127 char color_match_context
[COLOR_MAXLEN
];
128 char color_match_selected
[COLOR_MAXLEN
];
129 char color_selected
[COLOR_MAXLEN
];
130 char color_sep
[COLOR_MAXLEN
];
132 unsigned pre_context
;
133 unsigned post_context
;
140 void (*output
)(struct grep_opt
*opt
, const void *data
, size_t size
);
144 extern void init_grep_defaults(void);
145 extern int grep_config(const char *var
, const char *value
, void *);
146 extern void grep_init(struct grep_opt
*, const char *prefix
);
147 void grep_set_pattern_type_option(enum grep_pattern_type
, struct grep_opt
*opt
);
148 void grep_commit_pattern_type(enum grep_pattern_type
, struct grep_opt
*opt
);
150 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
);
151 extern void append_grep_pattern(struct grep_opt
*opt
, const char *pat
, const char *origin
, int no
, enum grep_pat_token t
);
152 extern void append_header_grep_pattern(struct grep_opt
*, enum grep_header_field
, const char *);
153 extern void compile_grep_patterns(struct grep_opt
*opt
);
154 extern void free_grep_patterns(struct grep_opt
*opt
);
155 extern int grep_buffer(struct grep_opt
*opt
, char *buf
, unsigned long size
);
160 enum grep_source_type
{
170 char *path
; /* for attribute lookups */
171 struct userdiff_driver
*driver
;
174 void grep_source_init(struct grep_source
*gs
, enum grep_source_type type
,
175 const char *name
, const char *path
,
176 const void *identifier
);
177 void grep_source_clear_data(struct grep_source
*gs
);
178 void grep_source_clear(struct grep_source
*gs
);
179 void grep_source_load_driver(struct grep_source
*gs
);
182 int grep_source(struct grep_opt
*opt
, struct grep_source
*gs
);
184 extern struct grep_opt
*grep_opt_dup(const struct grep_opt
*opt
);
185 extern int grep_threads_ok(const struct grep_opt
*opt
);
189 * Mutex used around access to the attributes machinery if
190 * opt->use_threads. Must be initialized/destroyed by callers!
192 extern int grep_use_locks
;
193 extern pthread_mutex_t grep_attr_mutex
;
194 extern pthread_mutex_t grep_read_mutex
;
196 static inline void grep_read_lock(void)
199 pthread_mutex_lock(&grep_read_mutex
);
202 static inline void grep_read_unlock(void)
205 pthread_mutex_unlock(&grep_read_mutex
);
209 #define grep_read_lock()
210 #define grep_read_unlock()