265 {
266 char *rtn;
267 char *ptr;
268 uint32_t offset = 0;
269 size_t len = 0;
270
271 if (!input)
272 return NULL;
273 else if (!*input)
274 return (char *) input;
275
276
277 while (isspace(*input))
278 input++;
279
280
281 ptr = ((char *) input) + strlen(input);
282 while (isspace(*--ptr))
283 offset++;
284
285 len = strlen(input) - offset + 1;
286 rtn =
rtalloc(
sizeof(
char) * len);
287 if (NULL == rtn) {
288 rterror(
_(
"trim: Not enough memory"));
289 return NULL;
290 }
291 strncpy(rtn, input, len);
292
293 return rtn;
294}
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.