From b0191ba570c731442f6395bb400cc955190dbcaf Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sat, 14 Mar 2015 20:40:37 +0000 Subject: [PATCH] New fiile. FossilOrigin-Name: 3cbf1deb9b9832bb33364e01ec99fd15fc6318105ccae2aebe612a65eb5f45b8 --- src/capwap/bstr_to_str.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/capwap/bstr_to_str.c 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