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