diff --git a/src/capwap/bstr_to_str.c b/src/capwap/bstr_to_str.c new file mode 100644 index 00000000..690e5f76 --- /dev/null +++ b/src/capwap/bstr_to_str.c @@ -0,0 +1,38 @@ +#include +#include + +#include "bstr.h" +#include "cw_util.h" + +int bstr_to_str(char *dst, bstr_t str,char * def) +{ + if (!str){ + if (!def) + return 0; + return sprintf(dst,"%s",def); + } + + int printable = cw_is_printable(bstr_data(str),bstr_len(str)); + int l=bstr_len(str); + + if (printable){ + memcpy((char*)dst,bstr_data(str),l); + *(dst+l)=0; + return l; + } + + int i; + int c=0; + char *s = dst; + for (i=0; i