]>
git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/lib/librte_eal/common/eal_common_string_fns.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #include <rte_string_fns.h>
12 /* split string into tokens */
14 rte_strsplit(char *string
, int stringlen
,
15 char **tokens
, int maxtokens
, char delim
)
18 int tokstart
= 1; /* first token is right at start of string */
20 if (string
== NULL
|| tokens
== NULL
)
23 for (i
= 0; i
< stringlen
; i
++) {
24 if (string
[i
] == '\0' || tok
>= maxtokens
)
28 tokens
[tok
++] = &string
[i
];
30 if (string
[i
] == delim
) {
42 /* Copy src string into dst.
44 * Return negative value and NUL-terminate if dst is too short,
45 * Otherwise return number of bytes copied.
48 rte_strscpy(char *dst
, const char *src
, size_t dsize
)
53 /* Copy as many bytes as will fit. */
62 /* Not enough room in dst, set NUL and return error. */