diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-12-30 12:28:03 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-12-30 12:28:03 +0200 |
commit | 7223eebbe71833e895fca95267cb243834dedf83 (patch) | |
tree | a5d48783316ff837e353c51a29b54f5324dd0bb1 /external/miniupnpc/upnpreplyparse.c | |
parent | Merge pull request #575 (diff) | |
parent | no longer need to pass the size to rapidjson (diff) | |
download | monero-7223eebbe71833e895fca95267cb243834dedf83.tar.xz |
Merge pull request #577
32a2633 no longer need to pass the size to rapidjson (Riccardo Spagni)
bd8e0fd add missing miniupnpc files, modify cmake to not build miniupnpc tests and to fix an issue with finding miniupnpcstrings (Riccardo Spagni)
7da9905 updated miniupnpc (Riccardo Spagni)
Diffstat (limited to 'external/miniupnpc/upnpreplyparse.c')
-rw-r--r-- | external/miniupnpc/upnpreplyparse.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/external/miniupnpc/upnpreplyparse.c b/external/miniupnpc/upnpreplyparse.c index dafa26313..5de5796a3 100644 --- a/external/miniupnpc/upnpreplyparse.c +++ b/external/miniupnpc/upnpreplyparse.c @@ -1,7 +1,7 @@ -/* $Id: upnpreplyparse.c,v 1.15 2013/06/06 21:36:40 nanard Exp $ */ +/* $Id: upnpreplyparse.c,v 1.19 2015/07/15 10:29:11 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2013 Thomas Bernard + * (c) 2006-2015 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -40,6 +40,15 @@ NameValueParserEndElt(void * d, const char * name, int l) /* standard case. Limited to n chars strings */ l = data->cdatalen; nv = malloc(sizeof(struct NameValue)); + if(nv == NULL) + { + /* malloc error */ +#ifdef DEBUG + fprintf(stderr, "%s: error allocating memory", + "NameValueParserEndElt"); +#endif /* DEBUG */ + return; + } if(l>=(int)sizeof(nv->value)) l = sizeof(nv->value) - 1; strncpy(nv->name, data->curelt, 64); @@ -53,7 +62,8 @@ NameValueParserEndElt(void * d, const char * name, int l) { nv->value[0] = '\0'; } - LIST_INSERT_HEAD( &(data->head), nv, entries); + nv->l_next = data->l_head; /* insert in list */ + data->l_head = nv; } data->cdata = NULL; data->cdatalen = 0; @@ -71,6 +81,10 @@ NameValueParserGetData(void * d, const char * datas, int l) if(!data->portListing) { /* malloc error */ +#ifdef DEBUG + fprintf(stderr, "%s: error allocating memory", + "NameValueParserGetData"); +#endif /* DEBUG */ return; } memcpy(data->portListing, datas, l); @@ -89,19 +103,19 @@ void ParseNameValue(const char * buffer, int bufsize, struct NameValueParserData * data) { - struct xmlparser parser; - LIST_INIT(&(data->head)); + struct xmlparser parser; + data->l_head = NULL; data->portListing = NULL; data->portListingLength = 0; - /* init xmlparser object */ - parser.xmlstart = buffer; - parser.xmlsize = bufsize; - parser.data = data; - parser.starteltfunc = NameValueParserStartElt; - parser.endeltfunc = NameValueParserEndElt; - parser.datafunc = NameValueParserGetData; + /* init xmlparser object */ + parser.xmlstart = buffer; + parser.xmlsize = bufsize; + parser.data = data; + parser.starteltfunc = NameValueParserStartElt; + parser.endeltfunc = NameValueParserEndElt; + parser.datafunc = NameValueParserGetData; parser.attfunc = 0; - parsexml(&parser); + parsexml(&parser); } void @@ -114,9 +128,9 @@ ClearNameValueList(struct NameValueParserData * pdata) pdata->portListing = NULL; pdata->portListingLength = 0; } - while((nv = pdata->head.lh_first) != NULL) + while((nv = pdata->l_head) != NULL) { - LIST_REMOVE(nv, entries); + pdata->l_head = nv->l_next; free(nv); } } @@ -127,9 +141,9 @@ GetValueFromNameValueList(struct NameValueParserData * pdata, { struct NameValue * nv; char * p = NULL; - for(nv = pdata->head.lh_first; + for(nv = pdata->l_head; (nv != NULL) && (p == NULL); - nv = nv->entries.le_next) + nv = nv->l_next) { if(strcmp(nv->name, Name) == 0) p = nv->value; @@ -171,13 +185,13 @@ DisplayNameValueList(char * buffer, int bufsize) struct NameValueParserData pdata; struct NameValue * nv; ParseNameValue(buffer, bufsize, &pdata); - for(nv = pdata.head.lh_first; + for(nv = pdata.l_head; nv != NULL; - nv = nv->entries.le_next) + nv = nv->l_next) { printf("%s = %s\n", nv->name, nv->value); } ClearNameValueList(&pdata); } -#endif +#endif /* DEBUG */ |