aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--include/tinyrad_internal.h5
-rw-r--r--lib/libtinyrad/libtinyrad.sym1
-rw-r--r--lib/libtinyrad/lstrings.c26
3 files changed, 32 insertions, 0 deletions
diff --git a/include/tinyrad_internal.h b/include/tinyrad_internal.h
index b3b569f..1b4238f 100644
--- a/include/tinyrad_internal.h
+++ b/include/tinyrad_internal.h
@@ -266,4 +266,9 @@ tinyrad_strtoargs(
266 int retain_quotes ); 266 int retain_quotes );
267 267
268 268
269_TINYRAD_F char *
270tinyrad_strtrim(
271 char * str );
272
273
269#endif /* end of header */ 274#endif /* end of header */
diff --git a/lib/libtinyrad/libtinyrad.sym b/lib/libtinyrad/libtinyrad.sym
index 3e791b5..8333fc6 100644
--- a/lib/libtinyrad/libtinyrad.sym
+++ b/lib/libtinyrad/libtinyrad.sym
@@ -112,6 +112,7 @@ tinyrad_strsdup
112tinyrad_strsfree 112tinyrad_strsfree
113tinyrad_strsplit 113tinyrad_strsplit
114tinyrad_strtoargs 114tinyrad_strtoargs
115tinyrad_strtrim
115# 116#
116# URL functions 117# URL functions
117tinyrad_is_radius_url 118tinyrad_is_radius_url
diff --git a/lib/libtinyrad/lstrings.c b/lib/libtinyrad/lstrings.c
index bfd58b6..ed80659 100644
--- a/lib/libtinyrad/lstrings.c
+++ b/lib/libtinyrad/lstrings.c
@@ -425,5 +425,31 @@ tinyrad_strtoargs(
425} 425}
426 426
427 427
428char *
429tinyrad_strtrim(
430 char * str )
431{
432 ssize_t offset;
433 ssize_t pos;
434
435 assert(str != NULL);
436
437 // find end of whitespace
438 for(offset = 0; ( ((str[offset])) && ((isspace(str[offset]))) ); offset++);
439
440 // shift string by offset
441 for(pos = offset; ((str[pos])); pos++)
442 str[pos-offset] = str[pos];
443 if (!(pos))
444 return(str);
445
446 // trim end of line
447 for(pos = pos - 1 - offset; ( ((isspace(str[pos]))) && (pos > 0) ); pos--);
448 str[pos+1] = '\0';
449
450 return(str);
451}
452
453
428 454
429/* end of source */ 455/* end of source */