cxstrutils.h
/*
* This file is part of the ESO C Extension Library
* Copyright (C) 2001-2026 European Southern Observatory
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CX_STRUTILS_H
#define CX_STRUTILS_H
#include <stdarg.h>
#include "cxmacros.h"
#include "cxtypes.h"
CX_BEGIN_DECLS
/*
* String comparison functions.
*/
cxint cx_strcasecmp(const cxchar *, const cxchar *);
cxint cx_strncasecmp(const cxchar *, const cxchar *, cxsize);
cxint cx_strempty(const cxchar *, const cxchar *);
/*
* Utility functions modifing their string argument
*/
cxchar *cx_strlower(cxchar *);
cxchar *cx_strupper(cxchar *);
cxchar *cx_strtrim(cxchar *);
cxchar *cx_strrtrim(cxchar *);
cxchar *cx_strstrip(cxchar *);
/*
* Utility functions which do not create a new string
*/
cxchar *cx_strskip(const cxchar *, cxint (*)(cxint));
/*
* Utilities returning a newly allocated string.
*/
cxchar *cx_strdup(const cxchar *);
cxchar *cx_strndup(const cxchar *, cxsize);
cxchar *cx_strvdupf(const cxchar *, va_list) CX_GNUC_PRINTF(1, 0);
cxchar *cx_stpcpy(cxchar *, const cxchar *);
cxchar **cx_strsplit(const cxchar *, const cxchar *, cxint);
void cx_strfreev(cxchar **sarray);
cxchar *cx_strjoinv(const cxchar *, cxchar **);
CX_END_DECLS
#endif /* CX_STRUTILS_H */
cx_strncasecmp
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
cx_strjoinv
cxchar * cx_strjoinv(const cxchar *, cxchar **)
Join strings from an array of strings.
Definition cxstrutils.c:704
cx_strcasecmp
cxint cx_strcasecmp(const cxchar *, const cxchar *)
Compare two strings ignoring the case of ASCII characters.
Definition cxstrutils.c:193
cx_strfreev
void cx_strfreev(cxchar **sarray)
Deallocate a NULL terminated string array.
Definition cxstrutils.c:578
cx_strrtrim
cxchar * cx_strrtrim(cxchar *)
Remove trailing whitespace characters from a string.
Definition cxstrutils.c:401
cx_stpcpy
cxchar cxchar * cx_stpcpy(cxchar *, const cxchar *)
Copy a string returning a pointer to its end.
Definition cxstrutils.c:559
cx_strempty
cxint cx_strempty(const cxchar *, const cxchar *)
Test if a string represents an empty string.
Definition cxstrutils.c:287
cx_strlower
cxchar * cx_strlower(cxchar *)
Convert all uppercase characters in a string into lowercase characters.
Definition cxstrutils.c:320
cx_strskip
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
cx_strupper
cxchar * cx_strupper(cxchar *)
Convert all lowercase characters in a string into uppercase characters.
Definition cxstrutils.c:351
cx_strvdupf
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
cx_strsplit
cxchar ** cx_strsplit(const cxchar *, const cxchar *, cxint)
Split a string into pieces at a given delimiter.
Definition cxstrutils.c:621
cx_strdup
cxchar * cx_strdup(const cxchar *)
Duplicate a string.
Definition cxstrutils.c:473
cx_strtrim
cxchar * cx_strtrim(cxchar *)
Remove leading whitespace characters from a string.
Definition cxstrutils.c:380
cx_strstrip
cxchar * cx_strstrip(cxchar *)
Remove leading and trailing whitespace characters from a string.
Definition cxstrutils.c:422
cx_strndup
cxchar * cx_strndup(const cxchar *, cxsize)
Duplicate the first n charactes of a string.
Definition cxstrutils.c:496