1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
8 * String-related functions as replacement for libc equivalents
11 #ifndef _RTE_STRING_FNS_H_
12 #define _RTE_STRING_FNS_H_
21 * Takes string "string" parameter and splits it at character "delim"
22 * up to maxtokens-1 times - to give "maxtokens" resulting tokens. Like
23 * strtok or strsep functions, this modifies its input string, by replacing
24 * instances of "delim" with '\\0'. All resultant tokens are returned in the
25 * "tokens" array which must have enough entries to hold "maxtokens".
28 * The input string to be split into tokens
31 * The max length of the input buffer
34 * The array to hold the pointers to the tokens in the string
37 * The number of elements in the tokens array. At most, maxtokens-1 splits
38 * of the string will be done.
41 * The character on which the split of the data will be done
44 * The number of tokens in the tokens array.
47 rte_strsplit(char *string, int stringlen,
48 char **tokens, int maxtokens, char delim);
52 * DPDK-specific version of strlcpy for systems without
53 * libc or libbsd copies of the function
56 rte_strlcpy(char *dst, const char *src, size_t size)
58 return (size_t)snprintf(dst, size, "%s", src);
61 /* pull in a strlcpy function */
62 #ifdef RTE_EXEC_ENV_BSDAPP
64 #ifndef __BSD_VISIBLE /* non-standard functions are hidden */
65 #define strlcpy(dst, src, size) rte_strlcpy(dst, src, size)
69 #else /* non-BSD platforms */
71 #include <bsd/string.h>
73 #else /* no BSD header files, create own */
74 #define strlcpy(dst, src, size) rte_strlcpy(dst, src, size)
76 #endif /* RTE_USE_LIBBSD */
83 #endif /* RTE_STRING_FNS_H */