New upstream version 18.02
[deb_dpdk.git] / lib / librte_eal / common / include / rte_string_fns.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 /**
6  * @file
7  *
8  * String-related functions as replacement for libc equivalents
9  */
10
11 #ifndef _RTE_STRING_FNS_H_
12 #define _RTE_STRING_FNS_H_
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /**
19  * Takes string "string" parameter and splits it at character "delim"
20  * up to maxtokens-1 times - to give "maxtokens" resulting tokens. Like
21  * strtok or strsep functions, this modifies its input string, by replacing
22  * instances of "delim" with '\\0'. All resultant tokens are returned in the
23  * "tokens" array which must have enough entries to hold "maxtokens".
24  *
25  * @param string
26  *   The input string to be split into tokens
27  *
28  * @param stringlen
29  *   The max length of the input buffer
30  *
31  * @param tokens
32  *   The array to hold the pointers to the tokens in the string
33  *
34  * @param maxtokens
35  *   The number of elements in the tokens array. At most, maxtokens-1 splits
36  *   of the string will be done.
37  *
38  * @param delim
39  *   The character on which the split of the data will be done
40  *
41  * @return
42  *   The number of tokens in the tokens array.
43  */
44 int
45 rte_strsplit(char *string, int stringlen,
46              char **tokens, int maxtokens, char delim);
47
48 #ifdef __cplusplus
49 }
50 #endif
51
52 #endif /* RTE_STRING_FNS_H */