C Standard Library Extensions 1.3.1
cxstrutils.h
1/*
2 * This file is part of the ESO C Extension Library
3 * Copyright (C) 2001-2026 European Southern Observatory
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef CX_STRUTILS_H
20#define CX_STRUTILS_H
21
22#include <stdarg.h>
23
24#include "cxmacros.h"
25#include "cxtypes.h"
26
27
28CX_BEGIN_DECLS
29
30/*
31 * String comparison functions.
32 */
33
34cxint cx_strcasecmp(const cxchar *, const cxchar *);
35cxint cx_strncasecmp(const cxchar *, const cxchar *, cxsize);
36cxint cx_strempty(const cxchar *, const cxchar *);
37
38
39/*
40 * Utility functions modifing their string argument
41 */
42
43cxchar *cx_strlower(cxchar *);
44cxchar *cx_strupper(cxchar *);
45
46cxchar *cx_strtrim(cxchar *);
47cxchar *cx_strrtrim(cxchar *);
48cxchar *cx_strstrip(cxchar *);
49
50
51/*
52 * Utility functions which do not create a new string
53 */
54
55cxchar *cx_strskip(const cxchar *, cxint (*)(cxint));
56
57
58/*
59 * Utilities returning a newly allocated string.
60 */
61
62cxchar *cx_strdup(const cxchar *);
63cxchar *cx_strndup(const cxchar *, cxsize);
64cxchar *cx_strvdupf(const cxchar *, va_list) CX_GNUC_PRINTF(1, 0);
65
66cxchar *cx_stpcpy(cxchar *, const cxchar *);
67
68cxchar **cx_strsplit(const cxchar *, const cxchar *, cxint);
69void cx_strfreev(cxchar **sarray);
70
71cxchar *cx_strjoinv(const cxchar *, cxchar **);
72
73CX_END_DECLS
74
75#endif /* CX_STRUTILS_H */
cxint cx_strncasecmp(const cxchar *, const cxchar *, cxsize)
Compare the first n characters of two strings ignoring the case of ASCII characters.
Definition cxstrutils.c:235
cxchar * cx_strjoinv(const cxchar *, cxchar **)
Join strings from an array of strings.
Definition cxstrutils.c:704
cxint cx_strcasecmp(const cxchar *, const cxchar *)
Compare two strings ignoring the case of ASCII characters.
Definition cxstrutils.c:193
void cx_strfreev(cxchar **sarray)
Deallocate a NULL terminated string array.
Definition cxstrutils.c:578
cxchar * cx_strrtrim(cxchar *)
Remove trailing whitespace characters from a string.
Definition cxstrutils.c:401
cxchar cxchar * cx_stpcpy(cxchar *, const cxchar *)
Copy a string returning a pointer to its end.
Definition cxstrutils.c:559
cxint cx_strempty(const cxchar *, const cxchar *)
Test if a string represents an empty string.
Definition cxstrutils.c:287
cxchar * cx_strlower(cxchar *)
Convert all uppercase characters in a string into lowercase characters.
Definition cxstrutils.c:320
cxchar * cx_strskip(const cxchar *, cxint(*)(cxint))
Locate the first character in a string that does not belong to a given character class.
Definition cxstrutils.c:450
cxchar * cx_strupper(cxchar *)
Convert all lowercase characters in a string into uppercase characters.
Definition cxstrutils.c:351
cxchar * cx_strvdupf(const cxchar *format, va_list args)
Create a string from a variable-length argument list under format control.
Definition cxstrutils.c:528
cxchar ** cx_strsplit(const cxchar *, const cxchar *, cxint)
Split a string into pieces at a given delimiter.
Definition cxstrutils.c:621
cxchar * cx_strdup(const cxchar *)
Duplicate a string.
Definition cxstrutils.c:473
cxchar * cx_strtrim(cxchar *)
Remove leading whitespace characters from a string.
Definition cxstrutils.c:380
cxchar * cx_strstrip(cxchar *)
Remove leading and trailing whitespace characters from a string.
Definition cxstrutils.c:422
cxchar * cx_strndup(const cxchar *, cxsize)
Duplicate the first n charactes of a string.
Definition cxstrutils.c:496