diff -r cff9c4101dd7 -r a9bbd82d2dce src/server/ucx/string.c --- a/src/server/ucx/string.c Sat Jan 14 14:33:38 2012 +0100 +++ b/src/server/ucx/string.c Sun Jan 15 17:00:16 2012 +0100 @@ -10,6 +10,7 @@ #include #include "string.h" +#include "mempool.h" sstr_t sstr (char *s) { sstr_t string; @@ -97,3 +98,40 @@ return newstring; } + + +// webserver extension +sstr_t sstrtrim(sstr_t string) { + sstr_t newstr = string; + int nsoff = 0; + int l = 1; + for(int i=0;i 32) { + l = 0; + nsoff = i; + newstr.ptr = &string.ptr[i]; + newstr.length = string.length - nsoff; + } + } else { + /* trailing whitespace */ + if(c > 32) { + newstr.length = (i - nsoff) + 1; + } + } + } + return newstr; +} + +sstr_t sstrdub_mp(UcxMempool *mp, sstr_t s) { + sstr_t newstring; + newstring.ptr = ucx_mempool_malloc(mp, s.length + 1); + newstring.length = s.length; + newstring.ptr[newstring.length] = 0; + + memcpy(newstring.ptr, s.ptr, s.length); + + return newstring; +}