wsutil: Add a reverse mempbrk function
This commit is contained in:
parent
0cec46bb25
commit
a6f3e61d70
|
@ -491,6 +491,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
ws_mempbrk_compile@Base 1.99.4
|
||||
ws_mempbrk_exec@Base 1.99.4
|
||||
ws_memrchr@Base 4.3.0rc0
|
||||
ws_memrpbrk_exec@Base 4.3.0rc0
|
||||
ws_optarg@Base 3.5.1
|
||||
ws_opterr@Base 3.5.1
|
||||
ws_optind@Base 3.5.1
|
||||
|
|
|
@ -72,6 +72,21 @@ ws_mempbrk_exec(const uint8_t* haystack, size_t haystacklen, const ws_mempbrk_pa
|
|||
return ws_mempbrk_portable_exec(haystack, haystacklen, pattern, found_needle);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
const uint8_t *haystack_end = haystack + haystacklen;
|
||||
|
||||
while (haystack_end > haystack) {
|
||||
if (pattern->patt[*(--haystack_end)]) {
|
||||
if (found_needle)
|
||||
*found_needle = *haystack_end;
|
||||
return haystack_end;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
|
|
|
@ -34,4 +34,9 @@ WS_DLL_PUBLIC void ws_mempbrk_compile(ws_mempbrk_pattern* pattern, const char *n
|
|||
*/
|
||||
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, starting at the
|
||||
* end of the haystack and working backwards.
|
||||
*/
|
||||
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);
|
||||
|
||||
#endif /* __WS_MEMPBRK_H__ */
|
||||
|
|
Loading…
Reference in New Issue