297 {
298 char *rtn = NULL;
299 char *ptr = NULL;
300 uint32_t offset = 0;
301 size_t len = 0;
302
303 if (!input)
304 return NULL;
305 else if (!*input)
306 return (char *) input;
307
308
309 while (strchr(remove, *input) != NULL)
310 input++;
311
312
313 ptr = ((char *) input) + strlen(input);
314 while (strchr(remove, *--ptr) != NULL)
315 offset++;
316
317 len = strlen(input) - offset + 1;
318 rtn =
rtalloc(
sizeof(
char) * len);
319 if (NULL == rtn) {
320 rterror(
_(
"chartrim: Not enough memory"));
321 return NULL;
322 }
323 strncpy(rtn, input, len);
324 rtn[strlen(input) - offset] = '\0';
325
326 return rtn;
327}
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.