diff options
author | Tobias Markmann <tm@ayena.de> | 2015-01-25 19:16:43 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2015-02-09 15:46:21 (GMT) |
commit | 415e2a0e26af19e00b7cafb58be72909ae1d8212 (patch) | |
tree | 945996fd950a3800e17a7897efb45d915b2537fc /3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c | |
parent | 1c64e31945e80e927f87a0a94ec5ce0e00c40a7f (diff) | |
download | swift-415e2a0e26af19e00b7cafb58be72909ae1d8212.zip swift-415e2a0e26af19e00b7cafb58be72909ae1d8212.tar.bz2 |
Update libminiupnpc to version 1.9
Fixes to our build of libminiupnpc:
* do not build minissdpc.c on windows
* if size of ip_mreqn is not defined, add -DNEED_STRUCT_IP_MREQN to the
CFLAGS
Test-Information:
Verified it still builds.
Change-Id: Idd3e19d6302cccc95fff0a01540b9abc1bc91e9e
Diffstat (limited to '3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c')
-rw-r--r-- | 3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c b/3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c index 482030b..dafa263 100644 --- a/3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c +++ b/3rdParty/LibMiniUPnPc/src/miniupnpc/upnpreplyparse.c @@ -1,7 +1,7 @@ -/* $Id: upnpreplyparse.c,v 1.11 2011/02/07 16:17:06 nanard Exp $ */ +/* $Id: upnpreplyparse.c,v 1.15 2013/06/06 21:36:40 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2011 Thomas Bernard + * (c) 2006-2013 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -15,18 +15,55 @@ static void NameValueParserStartElt(void * d, const char * name, int l) { - struct NameValueParserData * data = (struct NameValueParserData *)d; + struct NameValueParserData * data = (struct NameValueParserData *)d; + data->topelt = 1; if(l>63) l = 63; memcpy(data->curelt, name, l); data->curelt[l] = '\0'; + data->cdata = NULL; + data->cdatalen = 0; } static void -NameValueParserGetData(void * d, const char * datas, int l) +NameValueParserEndElt(void * d, const char * name, int l) { struct NameValueParserData * data = (struct NameValueParserData *)d; struct NameValue * nv; + (void)name; + (void)l; + if(!data->topelt) + return; + if(strcmp(data->curelt, "NewPortListing") != 0) + { + int l; + /* standard case. Limited to n chars strings */ + l = data->cdatalen; + nv = malloc(sizeof(struct NameValue)); + if(l>=(int)sizeof(nv->value)) + l = sizeof(nv->value) - 1; + strncpy(nv->name, data->curelt, 64); + nv->name[63] = '\0'; + if(data->cdata != NULL) + { + memcpy(nv->value, data->cdata, l); + nv->value[l] = '\0'; + } + else + { + nv->value[0] = '\0'; + } + LIST_INSERT_HEAD( &(data->head), nv, entries); + } + data->cdata = NULL; + data->cdatalen = 0; + data->topelt = 0; +} + +static void +NameValueParserGetData(void * d, const char * datas, int l) +{ + struct NameValueParserData * data = (struct NameValueParserData *)d; if(strcmp(data->curelt, "NewPortListing") == 0) { /* specific case for NewPortListing which is a XML Document */ @@ -42,15 +79,9 @@ NameValueParserGetData(void * d, const char * datas, int l) } else { - /* standard case. Limited to 63 chars strings */ - nv = malloc(sizeof(struct NameValue)); - if(l>63) - l = 63; - strncpy(nv->name, data->curelt, 64); - nv->name[63] = '\0'; - memcpy(nv->value, datas, l); - nv->value[l] = '\0'; - LIST_INSERT_HEAD( &(data->head), nv, entries); + /* standard case. */ + data->cdata = datas; + data->cdatalen = l; } } @@ -67,7 +98,7 @@ ParseNameValue(const char * buffer, int bufsize, parser.xmlsize = bufsize; parser.data = data; parser.starteltfunc = NameValueParserStartElt; - parser.endeltfunc = 0; + parser.endeltfunc = NameValueParserEndElt; parser.datafunc = NameValueParserGetData; parser.attfunc = 0; parsexml(&parser); @@ -90,7 +121,7 @@ ClearNameValueList(struct NameValueParserData * pdata) } } -char * +char * GetValueFromNameValueList(struct NameValueParserData * pdata, const char * Name) { @@ -131,7 +162,7 @@ GetValueFromNameValueListIgnoreNS(struct NameValueParserData * pdata, } #endif -/* debug all-in-one function +/* debug all-in-one function * do parsing then display to stdout */ #ifdef DEBUG void |