ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
grep.h
Go to the documentation of this file.
1
5
6#pragma once
7
9#define LOG_GREP_PATTERN_BUFFER_SIZE 4096
10
12#include <stdbool.h>
13#include <stddef.h>
14#include <stdint.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
37
53
63asciichat_error_t grep_init(const char *pattern);
64
76bool grep_should_output(const char *log_line, size_t *match_start,
77 size_t *match_len);
78
90const char *grep_highlight(const char *log_line, size_t match_start,
91 size_t match_len);
92
103const char *grep_highlight_colored(const char *colored_text,
104 const char *plain_text, size_t match_start,
105 size_t match_len);
106
120char *grep_highlight_colored_copy(const char *colored_text,
121 const char *plain_text, size_t match_start,
122 size_t match_len);
123
130void grep_destroy(void);
131
142
153
161void grep_clear_patterns(void);
162
168int grep_get_pattern_count(void);
169
179const char *grep_get_last_pattern(void);
180
181#ifdef __cplusplus
182}
183#endif
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
asciichat_error_t grep_restore_patterns(void)
Restore previously saved filter patterns.
Definition grep.c:1173
#define LOG_GREP_PATTERN_BUFFER_SIZE
Definition grep.h:9
asciichat_error_t grep_save_patterns(void)
Save current filter patterns for later restoration.
Definition grep.c:1157
char * grep_highlight_colored_copy(const char *colored_text, const char *plain_text, size_t match_start, size_t match_len)
Highlight matches in colored text, returning a new allocated copy.
Definition grep.c:686
const char * grep_get_last_pattern(void)
Get the last (most recent) filter pattern string.
Definition grep.c:1198
const char * grep_highlight(const char *log_line, size_t match_start, size_t match_len)
Highlight matched portion with background color.
Definition grep.c:1057
void grep_clear_patterns(void)
Clear all filter patterns.
Definition grep.c:1189
int grep_get_pattern_count(void)
Get number of active filter patterns.
Definition grep.c:1196
asciichat_error_t grep_init(const char *pattern)
Initialize log filtering with PCRE2 regex pattern.
Definition grep.c:418
void grep_destroy(void)
Clean up filter resources.
Definition grep.c:1065
bool grep_should_output(const char *log_line, size_t *match_start, size_t *match_len)
Check if log line should be output (matches filter).
Definition grep.c:529
grep_parse_result_t grep_parse_pattern(const char *input)
Parse pattern in /pattern/flags format or plain regex format.
Definition grep.c:269
const char * grep_highlight_colored(const char *colored_text, const char *plain_text, size_t match_start, size_t match_len)
Highlight matches in colored text while preserving original colors.
Definition grep.c:702
unsigned int uint32_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
Parsed pattern result from /pattern/flags syntax.
Definition grep.h:26
int context_before
Lines before match (B<n> flag).
Definition grep.h:33
bool global_flag
Highlight all matches (g flag).
Definition grep.h:32
bool is_fixed_string
True if fixed string (not regex).
Definition grep.h:29
bool invert
Invert match (I flag).
Definition grep.h:31
char pattern[4096]
Parsed pattern string.
Definition grep.h:27
bool case_insensitive
Case-insensitive (i flag).
Definition grep.h:30
bool valid
True if parsing succeeded.
Definition grep.h:35
int context_after
Lines after match (A<n> flag).
Definition grep.h:34
uint32_t pcre2_options
PCRE2 compile options.
Definition grep.h:28