|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
Centralized PCRE2 singleton pattern for efficient regex compilation. More...
Go to the source code of this file.
Data Structures | |
| struct | pcre2_singleton |
| Represents a thread-safe compiled PCRE2 regex singleton. More... | |
Typedefs | |
| typedef struct pcre2_singleton | pcre2_singleton_t |
| Represents a thread-safe compiled PCRE2 regex singleton. | |
Functions | |
| pcre2_code * | asciichat_pcre2_singleton_get_code (pcre2_singleton_t *singleton) |
| Get the compiled pcre2_code from a singleton handle. | |
| bool | asciichat_pcre2_singleton_is_initialized (pcre2_singleton_t *singleton) |
| Check if a singleton was successfully initialized. | |
| void | asciichat_pcre2_singleton_free (pcre2_singleton_t *singleton) |
| Free a PCRE2 singleton and its resources. | |
| void | asciichat_pcre2_cleanup_all (void) |
| Free all PCRE2 singletons in the global registry. | |
| char * | asciichat_pcre2_extract_named_group (pcre2_code *regex, pcre2_match_data *match_data, const char *group_name, const char *subject) |
| Extract named substring from PCRE2 match data. | |
| char * | asciichat_pcre2_extract_group (pcre2_match_data *match_data, int group_num, const char *subject) |
| Extract numbered capture group as allocated string. | |
| const char * | asciichat_pcre2_extract_group_ptr (pcre2_match_data *match_data, int group_num, const char *subject, size_t *out_len) |
| Extract numbered capture group as pointer into subject (non-allocating) | |
| bool | asciichat_pcre2_extract_group_ulong (pcre2_match_data *match_data, int group_num, const char *subject, unsigned long *out_value) |
| Extract numbered capture group and convert to unsigned long. | |
Centralized PCRE2 singleton pattern for efficient regex compilation.
Definition in file pcre2.c.
| typedef struct pcre2_singleton pcre2_singleton_t |
Represents a thread-safe compiled PCRE2 regex singleton.
Uses atomic flag for thread-safe lazy initialization without mutexes. The compilation flag is set only once, and the compiled code is read-only after that, enabling concurrent access from multiple threads.
| void asciichat_pcre2_cleanup_all | ( | void | ) |
Free all PCRE2 singletons in the global registry.
Walks the global registry and frees all singletons. Safe to call multiple times (idempotent). Should be called once during shutdown.
Definition at line 197 of file pcre2.c.
Referenced by asciichat_shared_destroy().
| char * asciichat_pcre2_extract_group | ( | pcre2_match_data * | match_data, |
| int | group_num, | ||
| const char * | subject | ||
| ) |
Extract numbered capture group as allocated string.
Definition at line 291 of file pcre2.c.
| const char * asciichat_pcre2_extract_group_ptr | ( | pcre2_match_data * | match_data, |
| int | group_num, | ||
| const char * | subject, | ||
| size_t * | out_len | ||
| ) |
Extract numbered capture group as pointer into subject (non-allocating)
Definition at line 322 of file pcre2.c.
Referenced by stun_servers_parse().
| bool asciichat_pcre2_extract_group_ulong | ( | pcre2_match_data * | match_data, |
| int | group_num, | ||
| const char * | subject, | ||
| unsigned long * | out_value | ||
| ) |
Extract numbered capture group and convert to unsigned long.
Definition at line 344 of file pcre2.c.
| char * asciichat_pcre2_extract_named_group | ( | pcre2_code * | regex, |
| pcre2_match_data * | match_data, | ||
| const char * | group_name, | ||
| const char * | subject | ||
| ) |
Extract named substring from PCRE2 match data.
Extracts a named capture group from match data and returns an allocated string. The caller is responsible for freeing the returned string with SAFE_FREE().
| regex | Compiled PCRE2 regex with named groups |
| match_data | Match data from pcre2_match() or pcre2_jit_match() |
| group_name | Name of the capture group to extract |
| subject | Original subject string that was matched |
Definition at line 252 of file pcre2.c.
Referenced by crypto_regex_extract_gpg_keygrip(), crypto_regex_extract_pem_base64(), crypto_regex_match_known_hosts(), crypto_regex_match_public_key(), and url_parse().
| void asciichat_pcre2_singleton_free | ( | pcre2_singleton_t * | singleton | ) |
Free a PCRE2 singleton and its resources.
Frees the compiled regex code, JIT stack, and singleton structure. After calling this, the singleton pointer is invalid and should not be used.
| singleton | Handle returned by asciichat_pcre2_singleton_compile() |
Definition at line 168 of file pcre2.c.
| pcre2_code * asciichat_pcre2_singleton_get_code | ( | pcre2_singleton_t * | singleton | ) |
Get the compiled pcre2_code from a singleton handle.
Lazily compiles the regex on first call. Fast path (subsequent calls) only reads a single atomic variable with no synchronization overhead.
Thread-safe: If multiple threads call this concurrently on first use, only one will compile; others will wait for the code to become non-NULL.
| singleton | Handle returned by asciichat_pcre2_singleton_compile() |
Definition at line 95 of file pcre2.c.
Referenced by grep_highlight(), grep_highlight_colored(), grep_init(), grep_should_output(), interactive_grep_enter_mode(), interactive_grep_exit_mode(), interactive_grep_gather_and_filter_logs(), interactive_grep_get_match_info(), and interactive_grep_handle_key().
| bool asciichat_pcre2_singleton_is_initialized | ( | pcre2_singleton_t * | singleton | ) |
Check if a singleton was successfully initialized.
| singleton | Handle returned by asciichat_pcre2_singleton_compile() |
Definition at line 153 of file pcre2.c.