171 |
171 |
172 return newstring; |
172 return newstring; |
173 } |
173 } |
174 |
174 |
175 // webserver extension |
175 // webserver extension |
|
176 |
|
177 int sstr_startswith(sstr_t string, sstr_t cmp) { |
|
178 sstr_t sub = sstrsubsl(string, 0, cmp.length); |
|
179 if(!sstrcmp(sub, cmp)) { |
|
180 return 1; |
|
181 } else { |
|
182 return 0; |
|
183 } |
|
184 } |
|
185 |
176 sstr_t sstrtrim(sstr_t string) { |
186 sstr_t sstrtrim(sstr_t string) { |
177 sstr_t newstr = string; |
187 sstr_t newstr = string; |
178 int nsoff = 0; |
188 int i; |
179 int l = 1; |
189 for(i=0;i<string.length;i++) { |
180 for(int i=0;i<string.length;i++) { |
|
181 char c = string.ptr[i]; |
190 char c = string.ptr[i]; |
182 if(l) { |
191 if(c > 32) { |
183 /* leading whitespace */ |
192 break; |
184 if(c > 32) { |
193 } |
185 l = 0; |
194 } |
186 nsoff = i; |
195 |
187 newstr.ptr = &string.ptr[i]; |
196 newstr.ptr = &string.ptr[i]; |
188 newstr.length = string.length - nsoff; |
197 newstr.length = string.length - i; |
189 } |
198 |
190 } else { |
199 for(i=newstr.length-1;i>=0;i--) { |
191 /* trailing whitespace */ |
200 char c = newstr.ptr[i]; |
192 if(c > 32) { |
201 if(c > 32) { |
193 newstr.length = (i - nsoff) + 1; |
202 break; |
194 } |
203 } |
195 } |
204 } |
196 } |
205 newstr.length = i + 1; |
|
206 |
197 return newstr; |
207 return newstr; |
198 } |
208 } |
199 |
209 |
200 sstr_t sstrdup_mp(UcxMempool *pool, sstr_t s) { |
210 sstr_t sstrdup_mp(UcxMempool *pool, sstr_t s) { |
201 sstr_t newstring; |
211 sstr_t newstring; |