ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
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
33
49
59asciichat_error_t grep_init(const char *pattern);
60
72bool grep_should_output(const char *log_line, size_t *match_start, size_t *match_len);
73
85const char *grep_highlight(const char *log_line, size_t match_start, size_t match_len);
86
96const char *grep_highlight_colored(const char *colored_text, const char *plain_text, size_t match_start,
97 size_t match_len);
98
111char *grep_highlight_colored_copy(const char *colored_text, const char *plain_text, size_t match_start,
112 size_t match_len);
113
120void grep_destroy(void);
121
132
143
151void grep_clear_patterns(void);
152
158int grep_get_pattern_count(void);
159
169const char *grep_get_last_pattern(void);
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:1108
#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:1093
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:656
const char * grep_get_last_pattern(void)
Get the last (most recent) filter pattern string.
Definition grep.c:1135
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:999
void grep_clear_patterns(void)
Clear all filter patterns.
Definition grep.c:1124
int grep_get_pattern_count(void)
Get number of active filter patterns.
Definition grep.c:1131
asciichat_error_t grep_init(const char *pattern)
Initialize log filtering with PCRE2 regex pattern.
Definition grep.c:412
void grep_destroy(void)
Clean up filter resources.
Definition grep.c:1005
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:512
grep_parse_result_t grep_parse_pattern(const char *input)
Parse pattern in /pattern/flags format or plain regex format.
Definition grep.c:265
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:670
unsigned int uint32_t
Definition common.h:62
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
Parsed pattern result from /pattern/flags syntax.
Definition grep.h:22
int context_before
Lines before match (B<n> flag).
Definition grep.h:29
bool global_flag
Highlight all matches (g flag).
Definition grep.h:28
bool is_fixed_string
True if fixed string (not regex).
Definition grep.h:25
bool invert
Invert match (I flag).
Definition grep.h:27
char pattern[4096]
Parsed pattern string.
Definition grep.h:23
bool case_insensitive
Case-insensitive (i flag).
Definition grep.h:26
bool valid
True if parsing succeeded.
Definition grep.h:31
int context_after
Lines after match (A<n> flag).
Definition grep.h:30
uint32_t pcre2_options
PCRE2 compile options.
Definition grep.h:24