11cb0ef41Sopenharmony_ci/* MIT License
21cb0ef41Sopenharmony_ci *
31cb0ef41Sopenharmony_ci * Copyright (c) 2018 John Schember
41cb0ef41Sopenharmony_ci *
51cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
61cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal
71cb0ef41Sopenharmony_ci * in the Software without restriction, including without limitation the rights
81cb0ef41Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
91cb0ef41Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is
101cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions:
111cb0ef41Sopenharmony_ci *
121cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice (including the next
131cb0ef41Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
141cb0ef41Sopenharmony_ci * Software.
151cb0ef41Sopenharmony_ci *
161cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
171cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
181cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
191cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
201cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
211cb0ef41Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
221cb0ef41Sopenharmony_ci * SOFTWARE.
231cb0ef41Sopenharmony_ci *
241cb0ef41Sopenharmony_ci * SPDX-License-Identifier: MIT
251cb0ef41Sopenharmony_ci */
261cb0ef41Sopenharmony_ci#ifndef HEADER_CARES_STRSPLIT_H
271cb0ef41Sopenharmony_ci#define HEADER_CARES_STRSPLIT_H
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci#include "ares_setup.h"
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci/* Split a string on delms skipping empty or duplicate elements.
321cb0ef41Sopenharmony_ci *
331cb0ef41Sopenharmony_ci * param in String to split.
341cb0ef41Sopenharmony_ci * param delms String of characters to treat as a delimiter.
351cb0ef41Sopenharmony_ci *             Each character in the string is a delimiter so
361cb0ef41Sopenharmony_ci *             there can be multiple delimiters to split on.
371cb0ef41Sopenharmony_ci *             E.g. ", " will split on all comma's and spaces.
381cb0ef41Sopenharmony_ci *             Duplicate (case-insensitive) entries are removed.
391cb0ef41Sopenharmony_ci * param num_elm Return parameter of the number of elements
401cb0ef41Sopenharmony_ci *               in the result array.
411cb0ef41Sopenharmony_ci *
421cb0ef41Sopenharmony_ci * returns an allocated array of allocated string elements.
431cb0ef41Sopenharmony_ci *
441cb0ef41Sopenharmony_ci */
451cb0ef41Sopenharmony_cichar **ares__strsplit(const char *in, const char *delms, size_t *num_elm);
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci/* Frees the result returned from ares__strsplit(). */
481cb0ef41Sopenharmony_civoid   ares__strsplit_free(char **elms, size_t num_elm);
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci/* Duplicate the array */
511cb0ef41Sopenharmony_cichar **ares__strsplit_duplicate(char **elms, size_t num_elm);
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci#endif /* HEADER_CARES_STRSPLIT_H */
54