1 /********************************************************************
3 strings.c - implementation of a string-handling routines
5 Niksa Orlic, 2004-04-19
7 ********************************************************************/
13 #include <stdlib.h>
14 #include <string.h>
16 /*
17 Create an empty string
18 */
20 {
38 }
41 /*
42 Create a copy of the string
43 */
45 {
57 memcpy(new_string->cstr, str->cstr, str->length + 1); /* also copy the terminating NULL character */
63 }
66 /*
67 Create a string from a C-style string
68 */
70 {
88 }
91 /*
92 Free all memory used by the string
93 */
95 {
98 }
101 /*
102 Empties the given string
103 */
105 {
108 }
111 /*
112 Append the second string to the first string
113 */
115 {
117 {
124 }
133 }
136 /*
137 Append the C-style string to the string
138 */
140 {
149 {
156 }
159 cstr2,
160 cstr2_length);
165 }
168 /*
169 Get the C-style string from a given string
170 */
172 {
174 }
177 /*
178 Get the string length
179 */
181 {
183 }
185 /*
186 Translate the string into lowercase
187 */
189 {
193 {
195 {
197 }
199 i++;
200 }
201 }