DPDK
25.11.0
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_string_fns.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright(c) 2010-2019 Intel Corporation
3
*/
4
10
11
#ifndef _RTE_STRING_FNS_H_
12
#define _RTE_STRING_FNS_H_
13
14
#include <ctype.h>
15
#include <stdio.h>
16
#include <string.h>
17
18
#include <
rte_common.h
>
19
#include <rte_compat.h>
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
51
int
52
rte_strsplit
(
char
*
string
,
int
stringlen,
53
char
**tokens,
int
maxtokens,
char
delim);
54
60
static
inline
size_t
61
rte_strlcpy(
char
*dst,
const
char
*src,
size_t
size)
62
{
63
return
(
size_t
)snprintf(dst, size,
"%s"
, src);
64
}
65
71
static
inline
size_t
72
rte_strlcat(
char
*dst,
const
char
*src,
size_t
size)
73
{
74
size_t
l = strnlen(dst, size);
75
if
(l < size)
76
return
l + rte_strlcpy(&dst[l], src, size - l);
77
return
l + strlen(src);
78
}
79
80
#ifdef __cplusplus
81
}
82
#endif
83
84
/* pull in a strlcpy function */
85
#ifdef RTE_EXEC_ENV_FREEBSD
86
#ifndef __BSD_VISIBLE
/* non-standard functions are hidden */
87
#define strlcpy(dst, src, size) rte_strlcpy(dst, src, size)
88
#define strlcat(dst, src, size) rte_strlcat(dst, src, size)
89
#endif
90
91
#else
/* non-BSD platforms */
92
#ifdef RTE_USE_LIBBSD
93
#include <bsd/string.h>
94
95
#else
/* no BSD header files, create own */
96
#define strlcpy(dst, src, size) rte_strlcpy(dst, src, size)
97
#define strlcat(dst, src, size) rte_strlcat(dst, src, size)
98
99
#endif
/* RTE_USE_LIBBSD */
100
#endif
/* FREEBSD */
101
102
#ifdef __cplusplus
103
extern
"C"
{
104
#endif
105
125
ssize_t
126
rte_strscpy
(
char
*dst,
const
char
*src,
size_t
dsize);
127
140
__rte_experimental
141
static
inline
const
char
*
142
rte_str_skip_leading_spaces
(
const
char
*src)
143
{
144
const
char
*p = src;
145
146
while
(isspace(*p))
147
p++;
148
149
return
p;
150
}
151
180
__rte_experimental
181
size_t
182
rte_basename
(
const
char
*path,
char
*buf,
size_t
buflen);
183
184
#ifdef __cplusplus
185
}
186
#endif
187
188
#endif
/* RTE_STRING_FNS_H */
rte_common.h
rte_basename
__rte_experimental size_t rte_basename(const char *path, char *buf, size_t buflen)
rte_str_skip_leading_spaces
static __rte_experimental const char * rte_str_skip_leading_spaces(const char *src)
Definition
rte_string_fns.h:142
rte_strscpy
ssize_t rte_strscpy(char *dst, const char *src, size_t dsize)
rte_strsplit
int rte_strsplit(char *string, int stringlen, char **tokens, int maxtokens, char delim)
lib
eal
include
rte_string_fns.h
Generated by
1.17.0