1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #include <rte_string_fns.h>
11 #include <rte_errno.h>
13 /* split string into tokens */
15 rte_strsplit(char *string, int stringlen,
16 char **tokens, int maxtokens, char delim)
19 int tokstart = 1; /* first token is right at start of string */
21 if (string == NULL || tokens == NULL)
24 for (i = 0; i < stringlen; i++) {
25 if (string[i] == '\0' || tok >= maxtokens)
29 tokens[tok++] = &string[i];
31 if (string[i] == delim) {
43 /* Copy src string into dst.
45 * Return negative value and NUL-terminate if dst is too short,
46 * Otherwise return number of bytes copied.
49 rte_strscpy(char *dst, const char *src, size_t dsize)
54 /* Copy as many bytes as will fit. */
63 /* Not enough room in dst, set NUL and return error. */