From 798c1996b77e9b886319198990960025f7d58595 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Fri, 1 May 2015 10:49:39 +0000 Subject: [PATCH] First fromstr function implemented. FossilOrigin-Name: b22bdf8b910513722aa8a699f22438d9ecf1567fd894876a412f759c160e2f07 --- src/capwap/mbag.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/capwap/mbag.c b/src/capwap/mbag.c index 19888185..2e70f455 100644 --- a/src/capwap/mbag.c +++ b/src/capwap/mbag.c @@ -30,6 +30,17 @@ static int mbag_strstr(void *item,char *dst) return sprintf(dst, "%s", (char*)i->data); } +static struct mbag_item * mbag_fromstr(const char *src) +{ + struct mbag_item *i= malloc(sizeof(mbag_item_t)); + if (!i) + return NULL; + + i->type = MBAG_STR; + i->data = strdup(src); + return i; +} + const struct mbag_typedef mbag_type_byte = { @@ -57,7 +68,7 @@ const struct mbag_typedef mbag_type_bstr16 = { }; const struct mbag_typedef mbag_type_str = { - "str",free,mbag_strstr + "str",free,mbag_strstr,mbag_fromstr }; const struct mbag_typedef mbag_type_vendorstr = {