274 {
275 char *rtn;
276 char *ptr;
277 uint32_t offset = 0;
278 size_t len = 0;
279
280 if (!input)
281 return NULL;
282 else if (!*input)
283 return (char *) input;
284
285
286 while (isspace(*input))
287 input++;
288
289
290 ptr = ((char *) input) + strlen(input);
291 while (isspace(*--ptr))
292 offset++;
293
294 len = strlen(input) - offset + 1;
295 rtn =
rtalloc(
sizeof(
char) * len);
296 if (NULL == rtn) {
297 rterror(
_(
"trim: Not enough memory"));
298 return NULL;
299 }
300 strncpy(rtn, input, len);
301
302 return rtn;
303}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.