Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Functions
ws_mempbrk.h File Reference
#include <wireshark.h>

Go to the source code of this file.

Classes

struct  ws_mempbrk_pattern
 

Functions

WS_DLL_PUBLIC void ws_mempbrk_compile (ws_mempbrk_pattern *pattern, const char *needles)
 Compile the pattern for the needles to find using ws_mempbrk_exec().
 
WS_DLL_PUBLIC const uint8_t * ws_mempbrk_exec (const uint8_t *haystack, size_t haystacklen, const ws_mempbrk_pattern *pattern, unsigned char *found_needle)
 Scan for the needles specified by the compiled pattern.
 
WS_DLL_PUBLIC const uint8_t * ws_memrpbrk_exec (const uint8_t *haystack, size_t haystacklen, const ws_mempbrk_pattern *pattern, unsigned char *found_needle)
 Scan for the needles specified by the compiled pattern, starting at the end of the haystack and working backwards.
 

Detailed Description

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Function Documentation

◆ ws_mempbrk_compile()

WS_DLL_PUBLIC void ws_mempbrk_compile ( ws_mempbrk_pattern pattern,
const char *  needles 
)

Compile the pattern for the needles to find using ws_mempbrk_exec().

Initializes the internal representation of the search pattern using the specified set of needle bytes. This enables efficient scanning of buffers for any matching byte.

Parameters
patternPointer to the pattern structure to initialize.
needlesNull-terminated string of bytes to search for.

◆ ws_mempbrk_exec()

WS_DLL_PUBLIC const uint8_t * ws_mempbrk_exec ( const uint8_t *  haystack,
size_t  haystacklen,
const ws_mempbrk_pattern pattern,
unsigned char *  found_needle 
)

Scan for the needles specified by the compiled pattern.

Searches the input buffer haystack for the first occurrence of any byte listed in the precompiled pattern. If a match is found, the matched byte is stored in found_needle (if non-NULL), and a pointer to its location in haystack is returned. Returns NULL if no match is found.

Parameters
haystackPointer to the input buffer to search.
haystacklenLength of the input buffer in bytes.
patternPrecompiled pattern containing target bytes.
found_needleOptional output pointer to receive the matched byte.
Returns
Pointer to the first matching byte in haystack, or NULL if none found.

◆ ws_memrpbrk_exec()

WS_DLL_PUBLIC const uint8_t * ws_memrpbrk_exec ( const uint8_t *  haystack,
size_t  haystacklen,
const ws_mempbrk_pattern pattern,
unsigned char *  found_needle 
)

Scan for the needles specified by the compiled pattern, starting at the end of the haystack and working backwards.

Searches the input buffer haystack in reverse for the first occurrence of any byte listed in the precompiled pattern. If a match is found, the matched byte is stored in found_needle (if non-NULL), and a pointer to its location in haystack is returned. Returns NULL if no match is found.

Parameters
haystackPointer to the input buffer to search.
haystacklenLength of the input buffer in bytes.
patternPrecompiled pattern containing target bytes.
found_needleOptional output pointer to receive the matched byte.
Returns
Pointer to the first matching byte in haystack, or NULL if none found.