]>
git.proxmox.com Git - mirror_frr.git/blob - lib/frrstr.h
2 * FRR string processing utilities.
3 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <sys/types.h>
35 * Tokenizes a string, storing tokens in a vector. Whitespace is ignored.
36 * Delimiter characters are not included.
42 * Delimiter string, as used in strsep()
45 * The split string. Each token is allocated with MTYPE_TMP.
47 void frrstr_split(const char *string
, const char *delimiter
, char ***result
,
49 vector
frrstr_split_vec(const char *string
, const char *delimiter
);
52 * Concatenate string array into a single string.
55 * array of string pointers to concatenate
61 * string to insert between each part, or NULL for nothing
64 * the joined string, allocated with MTYPE_TMP
66 char *frrstr_join(const char **parts
, int argc
, const char *join
);
67 char *frrstr_join_vec(vector v
, const char *join
);
70 * Filter string vector.
71 * Removes lines that do not contain a match for the provided regex.
74 * The vector to filter.
77 * Regex to filter with.
79 void frrstr_filter_vec(vector v
, regex_t
*filter
);
82 * Free allocated string vector.
83 * Assumes each item is allocated with MTYPE_TMP.
88 void frrstr_strvec_free(vector v
);
91 * Prefix match for string.
94 * string to check for prefix match
100 * true str starts with prefix, false otherwise
102 bool begins_with(const char *str
, const char *prefix
);
105 * Check the string only contains digit characters.
108 * string to check for digits
111 * 1 str only contains digit characters, 0 otherwise
113 int all_digit(const char *str
);
119 #endif /* _FRRSTR_H_ */