C Standard Library Extensions  1.2.3
cxstrutils.h
1 /*
2  * This file is part of the ESO C Extension Library
3  * Copyright (C) 2001-2017 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef CX_STRUTILS_H
21 #define CX_STRUTILS_H
22 
23 #include <stdarg.h>
24 #include <cxtypes.h>
25 
26 CX_BEGIN_DECLS
27 
28 /*
29  * String comparison functions.
30  */
31 
32 cxint cx_strcasecmp(const cxchar *, const cxchar *);
33 cxint cx_strncasecmp(const cxchar *, const cxchar *, cxsize);
34 cxint cx_strempty(const cxchar *, const cxchar *);
35 
36 
37 /*
38  * Utility functions modifing their string argument
39  */
40 
41 cxchar *cx_strlower(cxchar *);
42 cxchar *cx_strupper(cxchar *);
43 
44 cxchar *cx_strtrim(cxchar *);
45 cxchar *cx_strrtrim(cxchar *);
46 cxchar *cx_strstrip(cxchar *);
47 
48 
49 /*
50  * Utility functions which do not create a new string
51  */
52 
53 cxchar *cx_strskip(const cxchar *, cxint (*)(cxint));
54 
55 
56 /*
57  * Utilities returning a newly allocated string.
58  */
59 
60 cxchar *cx_strdup(const cxchar *);
61 cxchar *cx_strndup(const cxchar *, cxsize);
62 cxchar *cx_strvdupf(const cxchar *, va_list) CX_GNUC_PRINTF(1, 0);
63 
64 cxchar *cx_stpcpy(cxchar *, const cxchar *);
65 
66 cxchar **cx_strsplit(const cxchar *, const cxchar *, cxint);
67 void cx_strfreev(cxchar **sarray);
68 
69 cxchar *cx_strjoinv(const cxchar *, cxchar **);
70 
71 CX_END_DECLS
72 
73 #endif /* CX_STRUTILS_H */
cxchar * cx_strstrip(cxchar *)
Remove leading and trailing whitespace characters from a string.
Definition: cxstrutils.c:442
cxint cx_strcasecmp(const cxchar *, const cxchar *)
Compare two strings ignoring the case of ASCII characters.
Definition: cxstrutils.c:203
cxchar * cx_strndup(const cxchar *, cxsize)
Duplicate the first n charactes of a string.
Definition: cxstrutils.c:522
cxchar * cx_strupper(cxchar *)
Convert all lowercase characters in a string into uppercase characters.
Definition: cxstrutils.c:365
cxchar cxchar * cx_stpcpy(cxchar *, const cxchar *)
Copy a string returning a pointer to its end.
Definition: cxstrutils.c:588
cxchar * cx_strtrim(cxchar *)
Remove leading whitespace characters from a string.
Definition: cxstrutils.c:396
cxchar * cx_strrtrim(cxchar *)
Remove trailing whitespace characters from a string.
Definition: cxstrutils.c:419
cxint cx_strempty(const cxchar *, const cxchar *)
Test if a string represents an empty string.
Definition: cxstrutils.c:298
cxchar * cx_strvdupf(const cxchar *format, va_list args)
Create a string from a variable-length argument list under format control.
Definition: cxstrutils.c:556
cxchar * cx_strdup(const cxchar *)
Duplicate a string.
Definition: cxstrutils.c:497
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:472
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:246
cxchar * cx_strlower(cxchar *)
Convert all uppercase characters in a string into lowercase characters.
Definition: cxstrutils.c:332
cxchar ** cx_strsplit(const cxchar *, const cxchar *, cxint)
Split a string into pieces at a given delimiter.
Definition: cxstrutils.c:654
void cx_strfreev(cxchar **sarray)
Deallocate a NULL terminated string array.
Definition: cxstrutils.c:609
cxchar * cx_strjoinv(const cxchar *, cxchar **)
Join strings from an array of strings.
Definition: cxstrutils.c:736