2021-11-26 03:31:05 +00:00
|
|
|
/** @file
|
2012-10-24 02:04:40 +00:00
|
|
|
* Definitions for the Wireshark Memory Manager String Utilities
|
|
|
|
* Copyright 2012, Evan Huus <eapache@gmail.com>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-08 16:31:35 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2012-10-24 02:04:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WMEM_STRUTL_H__
|
|
|
|
#define __WMEM_STRUTL_H__
|
|
|
|
|
2021-12-18 13:48:29 +00:00
|
|
|
#include <stdarg.h>
|
2012-10-24 02:04:40 +00:00
|
|
|
|
2021-12-18 13:48:29 +00:00
|
|
|
#include "wmem_core.h"
|
2012-10-24 02:04:40 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2013-05-26 02:40:40 +00:00
|
|
|
/** @addtogroup wmem
|
|
|
|
* @{
|
|
|
|
* @defgroup wmem-strutl String Utilities
|
|
|
|
*
|
|
|
|
* A collection of utility function for operating on C strings with wmem.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-03-09 20:25:44 +00:00
|
|
|
WS_DLL_PUBLIC
|
2012-10-24 02:04:40 +00:00
|
|
|
gchar *
|
2013-04-25 22:54:36 +00:00
|
|
|
wmem_strdup(wmem_allocator_t *allocator, const gchar *src)
|
|
|
|
G_GNUC_MALLOC;
|
2012-10-24 02:04:40 +00:00
|
|
|
|
2021-12-18 21:11:20 +00:00
|
|
|
#define ws_strdup(src) wmem_strdup(NULL, src)
|
|
|
|
|
2013-03-09 20:25:44 +00:00
|
|
|
WS_DLL_PUBLIC
|
2012-10-24 02:04:40 +00:00
|
|
|
gchar *
|
2013-04-25 22:54:36 +00:00
|
|
|
wmem_strndup(wmem_allocator_t *allocator, const gchar *src, const size_t len)
|
|
|
|
G_GNUC_MALLOC;
|
2012-10-24 02:04:40 +00:00
|
|
|
|
2021-12-18 21:11:20 +00:00
|
|
|
#define ws_strndup(src, len) wmem_strndup(NULL, src, len)
|
|
|
|
|
2013-03-09 20:25:44 +00:00
|
|
|
WS_DLL_PUBLIC
|
2012-11-25 14:16:50 +00:00
|
|
|
gchar *
|
2013-04-25 22:54:36 +00:00
|
|
|
wmem_strdup_printf(wmem_allocator_t *allocator, const gchar *fmt, ...)
|
|
|
|
G_GNUC_MALLOC G_GNUC_PRINTF(2, 3);
|
2012-11-25 14:16:50 +00:00
|
|
|
|
2021-12-18 21:11:20 +00:00
|
|
|
#define ws_strdup_printf(...) wmem_strdup_printf(NULL, __VA_ARGS__)
|
|
|
|
|
2013-03-09 20:25:44 +00:00
|
|
|
WS_DLL_PUBLIC
|
2012-11-25 14:16:50 +00:00
|
|
|
gchar *
|
2013-04-25 22:54:36 +00:00
|
|
|
wmem_strdup_vprintf(wmem_allocator_t *allocator, const gchar *fmt, va_list ap)
|
|
|
|
G_GNUC_MALLOC;
|
2012-11-25 14:16:50 +00:00
|
|
|
|
2021-12-18 21:11:20 +00:00
|
|
|
#define ws_strdup_vprintf(fmt, ap) wmem_strdup_vprintf(NULL, fmt, ap)
|
|
|
|
|
2022-06-18 09:43:24 +00:00
|
|
|
/**
|
|
|
|
* Return the first occurrence of needle in haystack.
|
|
|
|
*
|
|
|
|
* @param haystack The data to search
|
|
|
|
* @param haystack_len The length of the search data
|
|
|
|
* @param needle The string to look for
|
|
|
|
* @param needle_len The length of the search string
|
|
|
|
* @return A pointer to the first occurrence of "needle" in
|
|
|
|
* "haystack". If "needle" isn't found or is NULL, or if
|
|
|
|
* "needle_len" is 0, NULL is returned.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
const guint8 *ws_memmem(const void *haystack, size_t haystack_len,
|
|
|
|
const void *needle, size_t needle_len);
|
|
|
|
|
2013-05-26 02:40:40 +00:00
|
|
|
/** @}
|
|
|
|
* @} */
|
|
|
|
|
2012-10-24 02:04:40 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* __WMEM_STRUTL_H__ */
|
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2012-10-24 02:04:40 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|