src/ucx/ucx/string.h

Mon, 25 Apr 2022 22:38:05 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 25 Apr 2022 22:38:05 +0200
branch
webdav
changeset 314
6b1a6066ee43
parent 260
4779a6fb4fbe
permissions
-rw-r--r--

fix pg propfind for getlastmodified property

254
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 * Bounded string implementation.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 * The UCX strings (<code>sstr_t</code>) provide an alternative to C strings.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 * The main difference to C strings is, that <code>sstr_t</code> does <b>not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 * need to be <code>NULL</code>-terminated</b>. Instead the length is stored
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 * within the structure.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 * When using <code>sstr_t</code>, developers must be full aware of what type
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 * of string (<code>NULL</code>-terminated) or not) they are using, when
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 * accessing the <code>char* ptr</code> directly.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 * The UCX string module provides some common string functions, known from
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 * standard libc, working with <code>sstr_t</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 * @file string.h
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 * @author Mike Becker
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 * @author Olaf Wintermann
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 #ifndef UCX_STRING_H
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 #define UCX_STRING_H
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 #include "ucx.h"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 #include "allocator.h"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 #include <stddef.h>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 /*
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 * Use this macro to disable the shortcuts if you experience macro collision.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 #ifndef UCX_NO_SSTR_SHORTCUTS
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 * Shortcut for a <code>sstr_t struct</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 * or <code>scstr_t struct</code> literal.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 #define ST(s) { s, sizeof(s)-1 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 #define S(s) sstrn(s, sizeof(s)-1)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 /** Shortcut for the conversion of a C string to a <code>scstr_t</code>. */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 #define SC(s) scstrn(s, sizeof(s)-1)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 #endif /* UCX_NO_SSTR_SHORTCUTS */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 /*
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 * Use this macro to disable the format macros.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 #ifndef UCX_NO_SSTR_FORMAT_MACROS
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 /** Expands a sstr_t or scstr_t to printf arguments. */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 #define SFMT(s) (int) (s).length, (s).ptr
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 /** Format specifier for a sstr_t or scstr_t. */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 #define PRIsstr ".*s"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 #endif /* UCX_NO_SSTR_FORMAT_MACROS */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 #ifdef __cplusplus
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 extern "C" {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 #endif
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 * The UCX string structure.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 typedef struct {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 /** A pointer to the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 * (<b>not necessarily <code>NULL</code>-terminated</b>) */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 char *ptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 /** The length of the string */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 size_t length;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 } sstr_t;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 * The UCX string structure for immutable (constant) strings.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 typedef struct {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 /** A constant pointer to the immutable string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 * (<b>not necessarily <code>NULL</code>-terminated</b>) */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 const char *ptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 /** The length of the string */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 size_t length;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 } scstr_t;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 #ifdef __cplusplus
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 #endif
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 #ifdef __cplusplus
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 * One of two type adjustment functions that return an scstr_t.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 * <b>Do not use this function manually.</b>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 * @param str some sstr_t
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 * @return an immutable (scstr_t) version of the provided string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 inline scstr_t s2scstr(sstr_t s) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 scstr_t c;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 c.ptr = s.ptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 c.length = s.length;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 return c;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 * One of two type adjustment functions that return an scstr_t.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 * This variant is used, when the string is already immutable and no operation
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 * needs to be performed.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 * <b>Do not use this function manually.</b>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 * @param str some scstr_t
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 * @return the argument itself
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 inline scstr_t s2scstr(scstr_t str) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 return str;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 * Converts a UCX string to an immutable UCX string (scstr_t).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 * @param str some UCX string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 * @return an immutable version of the provided string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 #define SCSTR(s) s2scstr(s)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 #else
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 * One of two type adjustment functions that return an scstr_t.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 * This variant is used, when the string is already immutable and no operation
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 * needs to be performed.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 * <b>Do not use this function manually.</b>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 * @param str some scstr_t
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 * @return the argument itself
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 scstr_t ucx_sc2sc(scstr_t str);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 * One of two type adjustment functions that return an scstr_t.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 * <b>Do not use this function manually.</b>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 * @param str some sstr_t
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 * @return an immutable (scstr_t) version of the provided string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 scstr_t ucx_ss2sc(sstr_t str);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 #if __STDC_VERSION__ >= 201112L
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 * Converts a UCX string to an immutable UCX string (scstr_t).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 * @param str some UCX string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 * @return an immutable version of the provided string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 #define SCSTR(str) _Generic(str, sstr_t: ucx_ss2sc, scstr_t: ucx_sc2sc)(str)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 #elif defined(__GNUC__) || defined(__clang__)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 * Converts a UCX string to an immutable UCX string (scstr_t).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 * @param str some UCX string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 * @return an immutable version of the provided string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 #define SCSTR(str) __builtin_choose_expr( \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 __builtin_types_compatible_p(typeof(str), sstr_t), \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 ucx_ss2sc, \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 ucx_sc2sc)(str)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 #elif defined(__sun)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 * Converts a UCX string to an immutable UCX string (scstr_t).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 * @param str some UCX string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 * @return the an immutable version of the provided string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 #define SCSTR(str) ({typeof(str) ucx_tmp_var_str = str; \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 scstr_t ucx_tmp_var_c; \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 ucx_tmp_var_c.ptr = ucx_tmp_var_str.ptr;\
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 ucx_tmp_var_c.length = ucx_tmp_var_str.length;\
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 ucx_tmp_var_c; })
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 #else /* no generics and no builtins */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 * Converts a UCX string to an immutable UCX string (scstr_t).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 * This <b>internal</b> function (ab)uses the C standard an expects one single
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 * argument which is then implicitly converted to scstr_t without a warning.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 * <b>Do not use this function manually.</b>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 * @return the an immutable version of the provided string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 scstr_t ucx_ss2c_s();
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 * Converts a UCX string to an immutable UCX string (scstr_t).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 * @param str some UCX string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 * @return the an immutable version of the provided string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 #define SCSTR(str) ucx_ss2c_s(str)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 #endif /* C11 feature test */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 #endif /* C++ */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 #ifdef __cplusplus
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 extern "C" {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 #endif
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 * Creates a new sstr_t based on a C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 * The length is implicitly inferred by using a call to <code>strlen()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 * <b>Note:</b> the sstr_t will share the specified pointer to the C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 * If you do want a copy, use sstrdup() on the return value of this function.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 * If you need to wrap a constant string, use scstr().
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 * @param cstring the C string to wrap
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 * @return a new sstr_t containing the C string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 * @see sstrn()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 sstr_t sstr(char *cstring);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 * Creates a new sstr_t of the specified length based on a C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 * <b>Note:</b> the sstr_t will share the specified pointer to the C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 * If you do want a copy, use sstrdup() on the return value of this function.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 * If you need to wrap a constant string, use scstrn().
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 * @param cstring the C string to wrap
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 * @param length the length of the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 * @return a new sstr_t containing the C string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 * @see sstr()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 * @see S()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 sstr_t sstrn(char *cstring, size_t length);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 * Creates a new scstr_t based on a constant C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 * The length is implicitly inferred by using a call to <code>strlen()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 * <b>Note:</b> the scstr_t will share the specified pointer to the C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 * If you do want a copy, use scstrdup() on the return value of this function.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 * @param cstring the C string to wrap
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 * @return a new scstr_t containing the C string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 * @see scstrn()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 scstr_t scstr(const char *cstring);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 * Creates a new scstr_t of the specified length based on a constant C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 * <b>Note:</b> the scstr_t will share the specified pointer to the C string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 * If you do want a copy, use scstrdup() on the return value of this function. *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 * @param cstring the C string to wrap
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 * @param length the length of the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 * @return a new scstr_t containing the C string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 * @see scstr()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 scstr_t scstrn(const char *cstring, size_t length);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 * Returns the accumulated length of all specified strings.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 * <b>Attention:</b> if the count argument is larger than the count of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 * specified strings, the behavior is undefined.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 * @param count the total number of specified strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 * @param ... all strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 * @return the accumulated length of all strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 size_t scstrnlen(size_t count, ...);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 * Returns the accumulated length of all specified strings.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 * <b>Attention:</b> if the count argument is larger than the count of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 * specified strings, the behavior is undefined.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 * @param count the total number of specified strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 * @param ... all strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 * @return the cumulated length of all strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 #define sstrnlen(count, ...) scstrnlen(count, __VA_ARGS__)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 * Concatenates two or more strings.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 * The resulting string will be allocated by standard <code>malloc()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 * So developers <b>MUST</b> pass the sstr_t.ptr to <code>free()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 * terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 * @param count the total number of strings to concatenate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 * @param s1 first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 * @param ... all remaining strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 * @return the concatenated string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 sstr_t scstrcat(size_t count, scstr_t s1, ...);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 * Concatenates two or more strings.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 * The resulting string will be allocated by standard <code>malloc()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 * So developers <b>MUST</b> pass the sstr_t.ptr to <code>free()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 * terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 * @param count the total number of strings to concatenate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 * @param s1 first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 * @param ... all remaining strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 * @return the concatenated string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 #define sstrcat(count, s1, ...) scstrcat(count, SCSTR(s1), __VA_ARGS__)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 * Concatenates two or more strings using a UcxAllocator.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 * The resulting string must be freed by the allocators <code>free()</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 * implementation.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 * terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 * @param alloc the allocator to use
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 * @param count the total number of strings to concatenate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 * @param s1 first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 * @param ... all remaining strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 * @return the concatenated string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378 * @see scstrcat()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 sstr_t scstrcat_a(UcxAllocator *alloc, size_t count, scstr_t s1, ...);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 * Concatenates two or more strings using a UcxAllocator.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 * The resulting string must be freed by the allocators <code>free()</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 * implementation.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 * terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 * @param alloc the allocator to use
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 * @param count the total number of strings to concatenate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393 * @param s1 first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 * @param ... all remaining strings
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 * @return the concatenated string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 * @see sstrcat()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399 #define sstrcat_a(alloc, count, s1, ...) \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 scstrcat_a(alloc, count, SCSTR(s1), __VA_ARGS__)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 * Returns a substring starting at the specified location.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 * <b>Attention:</b> the new string references the same memory area as the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 * input string and is <b>NOT</b> required to be <code>NULL</code>-terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 * Use sstrdup() to get a copy.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 * @param string input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 * @param start start location of the substring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 * @return a substring of <code>string</code> starting at <code>start</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 * @see sstrsubsl()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 * @see sstrchr()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 sstr_t sstrsubs(sstr_t string, size_t start);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419 * Returns a substring with the given length starting at the specified location.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 * <b>Attention:</b> the new string references the same memory area as the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 * input string and is <b>NOT</b> required to be <code>NULL</code>-terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 * Use sstrdup() to get a copy.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 * @param string input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 * @param start start location of the substring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 * @param length the maximum length of the substring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 * @return a substring of <code>string</code> starting at <code>start</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 * with a maximum length of <code>length</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 * @see sstrsubs()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432 * @see sstrchr()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 sstr_t sstrsubsl(sstr_t string, size_t start, size_t length);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437 * Returns a substring of an immutable string starting at the specified
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 * location.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 * <b>Attention:</b> the new string references the same memory area as the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 * input string and is <b>NOT</b> required to be <code>NULL</code>-terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 * Use scstrdup() to get a copy.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444 * @param string input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 * @param start start location of the substring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 * @return a substring of <code>string</code> starting at <code>start</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 * @see scstrsubsl()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449 * @see scstrchr()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 scstr_t scstrsubs(scstr_t string, size_t start);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 * Returns a substring of an immutable string with a maximum length starting
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 * at the specified location.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 * <b>Attention:</b> the new string references the same memory area as the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 * input string and is <b>NOT</b> required to be <code>NULL</code>-terminated.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 * Use scstrdup() to get a copy.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 * @param string input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462 * @param start start location of the substring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 * @param length the maximum length of the substring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 * @return a substring of <code>string</code> starting at <code>start</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 * with a maximum length of <code>length</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 * @see scstrsubs()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 * @see scstrchr()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 scstr_t scstrsubsl(scstr_t string, size_t start, size_t length);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 * Returns a substring starting at the location of the first occurrence of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 * specified character.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 * If the string does not contain the character, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478 * @param string the string where to locate the character
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 * @param chr the character to locate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 * @return a substring starting at the first location of <code>chr</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 * @see sstrsubs()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 sstr_t sstrchr(sstr_t string, int chr);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 * Returns a substring starting at the location of the last occurrence of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 * specified character.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490 * If the string does not contain the character, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
492 * @param string the string where to locate the character
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 * @param chr the character to locate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 * @return a substring starting at the last location of <code>chr</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
496 * @see sstrsubs()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498 sstr_t sstrrchr(sstr_t string, int chr);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
499
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
500 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501 * Returns an immutable substring starting at the location of the first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 * occurrence of the specified character.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 * If the string does not contain the character, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
506 * @param string the string where to locate the character
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 * @param chr the character to locate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 * @return a substring starting at the first location of <code>chr</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 * @see scstrsubs()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512 scstr_t scstrchr(scstr_t string, int chr);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 * Returns an immutable substring starting at the location of the last
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516 * occurrence of the specified character.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 * If the string does not contain the character, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
519 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 * @param string the string where to locate the character
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 * @param chr the character to locate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
522 * @return a substring starting at the last location of <code>chr</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
523 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
524 * @see scstrsubs()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
525 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
526 scstr_t scstrrchr(scstr_t string, int chr);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
528 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
529 * Returns a substring starting at the location of the first occurrence of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
530 * specified string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
532 * If the string does not contain the other string, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
533 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
534 * If <code>match</code> is an empty string, the complete <code>string</code> is
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
535 * returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
536 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
537 * @param string the string to be scanned
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
538 * @param match string containing the sequence of characters to match
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
539 * @return a substring starting at the first occurrence of
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540 * <code>match</code>, or an empty string, if the sequence is not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
541 * present in <code>string</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
542 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543 sstr_t scstrsstr(sstr_t string, scstr_t match);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
544
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
545 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
546 * Returns a substring starting at the location of the first occurrence of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
547 * specified string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
548 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
549 * If the string does not contain the other string, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
550 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
551 * If <code>match</code> is an empty string, the complete <code>string</code> is
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552 * returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554 * @param string the string to be scanned
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 * @param match string containing the sequence of characters to match
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 * @return a substring starting at the first occurrence of
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557 * <code>match</code>, or an empty string, if the sequence is not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 * present in <code>string</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 #define sstrstr(string, match) scstrsstr(string, SCSTR(match))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 * Returns an immutable substring starting at the location of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 * first occurrence of the specified immutable string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 * If the string does not contain the other string, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 * If <code>match</code> is an empty string, the complete <code>string</code> is
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 * returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 * @param string the string to be scanned
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 * @param match string containing the sequence of characters to match
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 * @return a substring starting at the first occurrence of
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 * <code>match</code>, or an empty string, if the sequence is not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 * present in <code>string</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
576 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577 scstr_t scstrscstr(scstr_t string, scstr_t match);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580 * Returns an immutable substring starting at the location of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 * first occurrence of the specified immutable string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 * If the string does not contain the other string, an empty string is returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 * If <code>match</code> is an empty string, the complete <code>string</code> is
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586 * returned.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
588 * @param string the string to be scanned
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 * @param match string containing the sequence of characters to match
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590 * @return a substring starting at the first occurrence of
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 * <code>match</code>, or an empty string, if the sequence is not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
592 * present in <code>string</code>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594 #define sstrscstr(string, match) scstrscstr(string, SCSTR(match))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
595
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
596 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597 * Splits a string into parts by using a delimiter string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 * This function will return <code>NULL</code>, if one of the following happens:
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
600 * <ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 * <li>the string length is zero</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602 * <li>the delimeter length is zero</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603 * <li>the string equals the delimeter</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 * <li>memory allocation fails</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605 * </ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
606 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
607 * The integer referenced by <code>count</code> is used as input and determines
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 * the maximum size of the resulting array, i.e. the maximum count of splits to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 * perform + 1.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
610 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 * The integer referenced by <code>count</code> is also used as output and is
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612 * set to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
613 * <ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
614 * <li>-2, on memory allocation errors</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
615 * <li>-1, if either the string or the delimiter is an empty string</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
616 * <li>0, if the string equals the delimiter</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
617 * <li>1, if the string does not contain the delimiter</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
618 * <li>the count of array items, otherwise</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
619 * </ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
620 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
621 * If the string starts with the delimiter, the first item of the resulting
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
622 * array will be an empty string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
623 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
624 * If the string ends with the delimiter and the maximum list size is not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
625 * exceeded, the last array item will be an empty string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
626 * In case the list size would be exceeded, the last array item will be the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
627 * remaining string after the last split, <i>including</i> the terminating
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
628 * delimiter.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
629 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
630 * <b>Attention:</b> The array pointer <b>AND</b> all sstr_t.ptr of the array
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
631 * items must be manually passed to <code>free()</code>. Use scstrsplit_a() with
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
632 * an allocator to managed memory, to avoid this.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
633 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
634 * @param string the string to split
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
635 * @param delim the delimiter string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636 * @param count IN: the maximum size of the resulting array (0 = no limit),
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
637 * OUT: the actual size of the array
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 * @return a sstr_t array containing the split strings or
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 * <code>NULL</code> on error
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
640 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
641 * @see scstrsplit_a()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 sstr_t* scstrsplit(scstr_t string, scstr_t delim, ssize_t *count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
644
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
645 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
646 * Splits a string into parts by using a delimiter string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
647 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
648 * This function will return <code>NULL</code>, if one of the following happens:
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
649 * <ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
650 * <li>the string length is zero</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
651 * <li>the delimeter length is zero</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
652 * <li>the string equals the delimeter</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
653 * <li>memory allocation fails</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
654 * </ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
655 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
656 * The integer referenced by <code>count</code> is used as input and determines
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
657 * the maximum size of the resulting array, i.e. the maximum count of splits to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
658 * perform + 1.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
659 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
660 * The integer referenced by <code>count</code> is also used as output and is
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
661 * set to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
662 * <ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
663 * <li>-2, on memory allocation errors</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
664 * <li>-1, if either the string or the delimiter is an empty string</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
665 * <li>0, if the string equals the delimiter</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
666 * <li>1, if the string does not contain the delimiter</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
667 * <li>the count of array items, otherwise</li>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
668 * </ul>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
669 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
670 * If the string starts with the delimiter, the first item of the resulting
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
671 * array will be an empty string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
672 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
673 * If the string ends with the delimiter and the maximum list size is not
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
674 * exceeded, the last array item will be an empty string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
675 * In case the list size would be exceeded, the last array item will be the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
676 * remaining string after the last split, <i>including</i> the terminating
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
677 * delimiter.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
678 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
679 * <b>Attention:</b> The array pointer <b>AND</b> all sstr_t.ptr of the array
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
680 * items must be manually passed to <code>free()</code>. Use sstrsplit_a() with
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
681 * an allocator to managed memory, to avoid this.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
682 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
683 * @param string the string to split
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
684 * @param delim the delimiter string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
685 * @param count IN: the maximum size of the resulting array (0 = no limit),
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
686 * OUT: the actual size of the array
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
687 * @return a sstr_t array containing the split strings or
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
688 * <code>NULL</code> on error
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
689 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
690 * @see sstrsplit_a()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
691 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
692 #define sstrsplit(string, delim, count) \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
693 scstrsplit(SCSTR(string), SCSTR(delim), count)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
694
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
695 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
696 * Performing scstrsplit() using a UcxAllocator.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
697 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
698 * <i>Read the description of scstrsplit() for details.</i>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
699 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
700 * The memory for the sstr_t.ptr pointers of the array items and the memory for
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
701 * the sstr_t array itself are allocated by using the UcxAllocator.malloc()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
702 * function.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
703 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
704 * @param allocator the UcxAllocator used for allocating memory
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
705 * @param string the string to split
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
706 * @param delim the delimiter string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
707 * @param count IN: the maximum size of the resulting array (0 = no limit),
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
708 * OUT: the actual size of the array
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
709 * @return a sstr_t array containing the split strings or
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
710 * <code>NULL</code> on error
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
711 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
712 * @see scstrsplit()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
713 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
714 sstr_t* scstrsplit_a(UcxAllocator *allocator, scstr_t string, scstr_t delim,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
715 ssize_t *count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
716
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
717 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
718 * Performing sstrsplit() using a UcxAllocator.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
719 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
720 * <i>Read the description of sstrsplit() for details.</i>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
721 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
722 * The memory for the sstr_t.ptr pointers of the array items and the memory for
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
723 * the sstr_t array itself are allocated by using the UcxAllocator.malloc()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
724 * function.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
725 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
726 * @param allocator the UcxAllocator used for allocating memory
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
727 * @param string the string to split
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
728 * @param delim the delimiter string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
729 * @param count IN: the maximum size of the resulting array (0 = no limit),
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
730 * OUT: the actual size of the array
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
731 * @return a sstr_t array containing the split strings or
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
732 * <code>NULL</code> on error
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
733 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
734 * @see sstrsplit()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
735 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
736 #define sstrsplit_a(allocator, string, delim, count) \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
737 scstrsplit_a(allocator, SCSTR(string), SCSTR(delim), count)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
738
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
739 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
740 * Compares two UCX strings with standard <code>memcmp()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
741 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
742 * At first it compares the scstr_t.length attribute of the two strings. The
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
743 * <code>memcmp()</code> function is called, if and only if the lengths match.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
744 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
745 * @param s1 the first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
746 * @param s2 the second string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
747 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
748 * length of s1 is greater than the length of s2 or the result of
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
749 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
750 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
751 int scstrcmp(scstr_t s1, scstr_t s2);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
752
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
753 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
754 * Compares two UCX strings with standard <code>memcmp()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
755 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
756 * At first it compares the sstr_t.length attribute of the two strings. The
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
757 * <code>memcmp()</code> function is called, if and only if the lengths match.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
758 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
759 * @param s1 the first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
760 * @param s2 the second string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
761 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
762 * length of s1 is greater than the length of s2 or the result of
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
763 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
764 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
765 #define sstrcmp(s1, s2) scstrcmp(SCSTR(s1), SCSTR(s2))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
766
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
767 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
768 * Compares two UCX strings ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
769 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
770 * At first it compares the scstr_t.length attribute of the two strings. If and
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
771 * only if the lengths match, both strings are compared char by char ignoring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
772 * the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
773 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
774 * @param s1 the first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
775 * @param s2 the second string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
776 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
777 * length of s1 is greater than the length of s2 or the result of the platform
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
778 * specific string comparison function ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
779 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
780 int scstrcasecmp(scstr_t s1, scstr_t s2);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
781
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
782 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
783 * Compares two UCX strings ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
784 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
785 * At first it compares the sstr_t.length attribute of the two strings. If and
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
786 * only if the lengths match, both strings are compared char by char ignoring
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
787 * the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
788 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
789 * @param s1 the first string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
790 * @param s2 the second string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
791 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
792 * length of s1 is greater than the length of s2 or the result of the platform
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
793 * specific string comparison function ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
794 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
795 #define sstrcasecmp(s1, s2) scstrcasecmp(SCSTR(s1), SCSTR(s2))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
796
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
797 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
798 * Creates a duplicate of the specified string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
799 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
800 * The new sstr_t will contain a copy allocated by standard
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
801 * <code>malloc()</code>. So developers <b>MUST</b> pass the sstr_t.ptr to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
802 * <code>free()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
803 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
804 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
805 * terminated and mutable, regardless of the argument.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
806 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
807 * @param string the string to duplicate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
808 * @return a duplicate of the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
809 * @see scstrdup_a()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
810 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
811 sstr_t scstrdup(scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
812
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
813 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
814 * Creates a duplicate of the specified string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
815 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
816 * The new sstr_t will contain a copy allocated by standard
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
817 * <code>malloc()</code>. So developers <b>MUST</b> pass the sstr_t.ptr to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
818 * <code>free()</code>.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
819 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
820 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
821 * terminated, regardless of the argument.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
822 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
823 * @param string the string to duplicate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
824 * @return a duplicate of the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
825 * @see sstrdup_a()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
826 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
827 #define sstrdup(string) scstrdup(SCSTR(string))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
828
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
829 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
830 * Creates a duplicate of the specified string using a UcxAllocator.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
831 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
832 * The new sstr_t will contain a copy allocated by the allocators
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
833 * UcxAllocator.malloc() function. So it is implementation depended, whether the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
834 * returned sstr_t.ptr pointer must be passed to the allocators
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
835 * UcxAllocator.free() function manually.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
836 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
837 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
838 * terminated and mutable, regardless of the argument.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
839 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
840 * @param allocator a valid instance of a UcxAllocator
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
841 * @param string the string to duplicate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
842 * @return a duplicate of the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
843 * @see scstrdup()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
844 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
845 sstr_t scstrdup_a(UcxAllocator *allocator, scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
846
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
847 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
848 * Creates a duplicate of the specified string using a UcxAllocator.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
849 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
850 * The new sstr_t will contain a copy allocated by the allocators
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
851 * UcxAllocator.malloc() function. So it is implementation depended, whether the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
852 * returned sstr_t.ptr pointer must be passed to the allocators
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
853 * UcxAllocator.free() function manually.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
854 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
855 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
856 * terminated, regardless of the argument.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
857 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
858 * @param allocator a valid instance of a UcxAllocator
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
859 * @param string the string to duplicate
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
860 * @return a duplicate of the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
861 * @see scstrdup()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
862 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
863 #define sstrdup_a(allocator, string) scstrdup_a(allocator, SCSTR(string))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
864
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
865
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
866 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
867 * Omits leading and trailing spaces.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
868 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
869 * This function returns a new sstr_t containing a trimmed version of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
870 * specified string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
871 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
872 * <b>Note:</b> the new sstr_t references the same memory, thus you
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
873 * <b>MUST NOT</b> pass the sstr_t.ptr of the return value to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
874 * <code>free()</code>. It is also highly recommended to avoid assignments like
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
875 * <code>mystr = sstrtrim(mystr);</code> as you lose the reference to the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
876 * source string. Assignments of this type are only permitted, if the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
877 * sstr_t.ptr of the source string does not need to be freed or if another
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
878 * reference to the source string exists.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
879 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
880 * @param string the string that shall be trimmed
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
881 * @return a new sstr_t containing the trimmed string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
882 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
883 sstr_t sstrtrim(sstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
884
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
885 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
886 * Omits leading and trailing spaces.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
887 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
888 * This function returns a new scstr_t containing a trimmed version of the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
889 * specified string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
890 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
891 * <b>Note:</b> the new scstr_t references the same memory, thus you
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
892 * <b>MUST NOT</b> pass the scstr_t.ptr of the return value to
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
893 * <code>free()</code>. It is also highly recommended to avoid assignments like
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
894 * <code>mystr = scstrtrim(mystr);</code> as you lose the reference to the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
895 * source string. Assignments of this type are only permitted, if the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
896 * scstr_t.ptr of the source string does not need to be freed or if another
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
897 * reference to the source string exists.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
898 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
899 * @param string the string that shall be trimmed
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
900 * @return a new scstr_t containing the trimmed string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
901 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
902 scstr_t scstrtrim(scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
903
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
904 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
905 * Checks, if a string has a specific prefix.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
906 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
907 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
908 * @param prefix the prefix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
909 * @return 1, if and only if the string has the specified prefix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
910 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
911 int scstrprefix(scstr_t string, scstr_t prefix);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
912
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
913 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
914 * Checks, if a string has a specific prefix.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
915 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
916 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
917 * @param prefix the prefix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
918 * @return 1, if and only if the string has the specified prefix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
919 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
920 #define sstrprefix(string, prefix) scstrprefix(SCSTR(string), SCSTR(prefix))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
921
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
922 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
923 * Checks, if a string has a specific suffix.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
924 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
925 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
926 * @param suffix the suffix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
927 * @return 1, if and only if the string has the specified suffix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
928 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
929 int scstrsuffix(scstr_t string, scstr_t suffix);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
930
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
931 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
932 * Checks, if a string has a specific suffix.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
933 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
934 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
935 * @param suffix the suffix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
936 * @return 1, if and only if the string has the specified suffix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
937 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
938 #define sstrsuffix(string, suffix) scstrsuffix(SCSTR(string), SCSTR(suffix))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
939
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
940 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
941 * Checks, if a string has a specific prefix, ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
942 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
943 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
944 * @param prefix the prefix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
945 * @return 1, if and only if the string has the specified prefix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
946 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
947 int scstrcaseprefix(scstr_t string, scstr_t prefix);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
948
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
949 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
950 * Checks, if a string has a specific prefix, ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
951 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
952 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
953 * @param prefix the prefix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
954 * @return 1, if and only if the string has the specified prefix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
955 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
956 #define sstrcaseprefix(string, prefix) \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
957 scstrcaseprefix(SCSTR(string), SCSTR(prefix))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
958
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
959 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
960 * Checks, if a string has a specific suffix, ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
961 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
962 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
963 * @param suffix the suffix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
964 * @return 1, if and only if the string has the specified suffix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
965 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
966 int scstrcasesuffix(scstr_t string, scstr_t suffix);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
967
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
968 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
969 * Checks, if a string has a specific suffix, ignoring the case.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
970 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
971 * @param string the string to check
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
972 * @param suffix the suffix the string should have
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
973 * @return 1, if and only if the string has the specified suffix, 0 otherwise
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
974 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
975 #define sstrcasesuffix(string, suffix) \
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
976 scstrcasesuffix(SCSTR(string), SCSTR(suffix))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
977
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
978 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
979 * Returns a lower case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
980 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
981 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
982 * (see scstrdup()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
983 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
984 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
985 * @return the resulting lower case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
986 * @see scstrdup()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
987 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
988 sstr_t scstrlower(scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
989
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
990 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
991 * Returns a lower case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
992 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
993 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
994 * (see sstrdup()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
995 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
996 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
997 * @return the resulting lower case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
998 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
999 #define sstrlower(string) scstrlower(SCSTR(string))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1000
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1001 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1002 * Returns a lower case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1003 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1004 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1005 * (see scstrdup_a()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1006 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1007 * @param allocator the allocator used for duplicating the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1008 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1009 * @return the resulting lower case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1010 * @see scstrdup_a()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1011 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1012 sstr_t scstrlower_a(UcxAllocator *allocator, scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1013
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1014
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1015 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1016 * Returns a lower case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1017 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1018 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1019 * (see sstrdup_a()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1020 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1021 * @param allocator the allocator used for duplicating the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1022 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1023 * @return the resulting lower case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1024 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1025 #define sstrlower_a(allocator, string) scstrlower_a(allocator, SCSTR(string))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1026
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1027 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1028 * Returns a upper case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1029 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1030 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1031 * (see scstrdup()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1032 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1033 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1034 * @return the resulting upper case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1035 * @see scstrdup()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1036 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1037 sstr_t scstrupper(scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1038
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1039 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1040 * Returns a upper case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1041 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1042 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1043 * (see sstrdup()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1044 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1045 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1046 * @return the resulting upper case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1047 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1048 #define sstrupper(string) scstrupper(SCSTR(string))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1049
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1050 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1051 * Returns a upper case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1052 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1053 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1054 * (see scstrdup_a()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1055 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1056 * @param allocator the allocator used for duplicating the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1057 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1058 * @return the resulting upper case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1059 * @see scstrdup_a()
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1060 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1061 sstr_t scstrupper_a(UcxAllocator *allocator, scstr_t string);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1062
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1063 /**
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1064 * Returns a upper case version of a string.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1065 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1066 * This function creates a duplicate of the input string, first
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1067 * (see sstrdup_a()).
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1068 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1069 * @param allocator the allocator used for duplicating the string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1070 * @param string the input string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1071 * @return the resulting upper case string
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1072 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1073 #define sstrupper_a(allocator, string) scstrupper_a(allocator, string)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1074
260
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1075
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1076 /**
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1077 * Replaces a pattern in a string with another string.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1078 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1079 * The pattern is taken literally and is no regular expression.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1080 * Replaces at most <code>replmax</code> occurrences.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1081 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1082 * The resulting string is allocated by the specified allocator. I.e. it
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1083 * depends on the used allocator, whether the sstr_t.ptr must be freed
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1084 * manually.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1085 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1086 * If allocation fails, the sstr_t.ptr of the return value is NULL.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1087 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1088 * @param allocator the allocator to use
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1089 * @param str the string where replacements should be applied
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1090 * @param pattern the pattern to search for
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1091 * @param replacement the replacement string
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1092 * @param replmax maximum number of replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1093 * @return the resulting string after applying the replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1094 */
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1095 sstr_t scstrreplacen_a(UcxAllocator *allocator, scstr_t str,
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1096 scstr_t pattern, scstr_t replacement, size_t replmax);
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1097
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1098 /**
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1099 * Replaces a pattern in a string with another string.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1100 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1101 * The pattern is taken literally and is no regular expression.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1102 * Replaces at most <code>replmax</code> occurrences.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1103 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1104 * The sstr_t.ptr of the resulting string must be freed manually.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1105 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1106 * If allocation fails, the sstr_t.ptr of the return value is NULL.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1107 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1108 * @param str the string where replacements should be applied
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1109 * @param pattern the pattern to search for
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1110 * @param replacement the replacement string
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1111 * @param replmax maximum number of replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1112 * @return the resulting string after applying the replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1113 */
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1114 sstr_t scstrreplacen(scstr_t str, scstr_t pattern,
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1115 scstr_t replacement, size_t replmax);
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1116
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1117 /**
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1118 * Replaces a pattern in a string with another string.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1119 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1120 * The pattern is taken literally and is no regular expression.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1121 * Replaces at most <code>replmax</code> occurrences.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1122 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1123 * The resulting string is allocated by the specified allocator. I.e. it
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1124 * depends on the used allocator, whether the sstr_t.ptr must be freed
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1125 * manually.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1126 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1127 * @param allocator the allocator to use
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1128 * @param str the string where replacements should be applied
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1129 * @param pattern the pattern to search for
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1130 * @param replacement the replacement string
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1131 * @param replmax maximum number of replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1132 * @return the resulting string after applying the replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1133 */
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1134 #define sstrreplacen_a(allocator, str, pattern, replacement, replmax) \
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1135 scstrreplacen_a(allocator, SCSTR(str), SCSTR(pattern), \
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1136 SCSTR(replacement), replmax)
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1137
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1138 /**
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1139 * Replaces a pattern in a string with another string.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1140 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1141 * The pattern is taken literally and is no regular expression.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1142 * Replaces at most <code>replmax</code> occurrences.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1143 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1144 * The sstr_t.ptr of the resulting string must be freed manually.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1145 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1146 * If allocation fails, the sstr_t.ptr of the return value is NULL.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1147 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1148 * @param str the string where replacements should be applied
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1149 * @param pattern the pattern to search for
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1150 * @param replacement the replacement string
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1151 * @param replmax maximum number of replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1152 * @return the resulting string after applying the replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1153 */
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1154 #define sstrreplacen(str, pattern, replacement, replmax) \
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1155 scstrreplacen(SCSTR(str), SCSTR(pattern), SCSTR(replacement), replmax)
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1156
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1157 /**
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1158 * Replaces a pattern in a string with another string.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1159 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1160 * The pattern is taken literally and is no regular expression.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1161 * Replaces at most <code>replmax</code> occurrences.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1162 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1163 * The resulting string is allocated by the specified allocator. I.e. it
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1164 * depends on the used allocator, whether the sstr_t.ptr must be freed
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1165 * manually.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1166 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1167 * If allocation fails, the sstr_t.ptr of the return value is NULL.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1168 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1169 * @param allocator the allocator to use
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1170 * @param str the string where replacements should be applied
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1171 * @param pattern the pattern to search for
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1172 * @param replacement the replacement string
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1173 * @return the resulting string after applying the replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1174 */
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1175 #define sstrreplace_a(allocator, str, pattern, replacement) \
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1176 scstrreplacen_a(allocator, SCSTR(str), SCSTR(pattern), \
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1177 SCSTR(replacement), SIZE_MAX)
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1178
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1179 /**
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1180 * Replaces a pattern in a string with another string.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1181 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1182 * The pattern is taken literally and is no regular expression.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1183 * Replaces at most <code>replmax</code> occurrences.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1184 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1185 * The sstr_t.ptr of the resulting string must be freed manually.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1186 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1187 * If allocation fails, the sstr_t.ptr of the return value is NULL.
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1188 *
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1189 * @param str the string where replacements should be applied
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1190 * @param pattern the pattern to search for
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1191 * @param replacement the replacement string
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1192 * @return the resulting string after applying the replacements
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1193 */
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1194 #define sstrreplace(str, pattern, replacement) \
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1195 scstrreplacen(SCSTR(str), SCSTR(pattern), SCSTR(replacement), SIZE_MAX)
4779a6fb4fbe fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
1196
254
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1197 #ifdef __cplusplus
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1198 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1199 #endif
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1200
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1201 #endif /* UCX_STRING_H */

mercurial