aboutsummaryrefslogtreecommitdiff
path: root/external/miniupnpc/upnpreplyparse.c
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-12-30 09:56:25 +0200
committerRiccardo Spagni <ric@spagni.net>2015-12-30 09:56:25 +0200
commit7da99055891baaa453d7d575985bc9824cf5f47c (patch)
tree95471106647425de916ca4595c145ef0464ea624 /external/miniupnpc/upnpreplyparse.c
parentMerge pull request #575 (diff)
downloadmonero-7da99055891baaa453d7d575985bc9824cf5f47c.tar.xz
updated miniupnpc
Diffstat (limited to 'external/miniupnpc/upnpreplyparse.c')
-rw-r--r--external/miniupnpc/upnpreplyparse.c54
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 */