* Add a flag to tell ParseNameValue() to store empty XML elements.
This commit is contained in:
parent
074055aa4d
commit
f0c7768533
@ -372,7 +372,7 @@ image_get_jpeg_date_xmp(const char * path, char ** date)
|
|||||||
if( nread < 1 )
|
if( nread < 1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ParseNameValue(data, offset, &xml);
|
ParseNameValue(data, offset, &xml, 0);
|
||||||
exif = GetValueFromNameValueList(&xml, "DateTimeOriginal");
|
exif = GetValueFromNameValueList(&xml, "DateTimeOriginal");
|
||||||
if( !exif )
|
if( !exif )
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ parse_nfo(const char *path, metadata_t *m)
|
|||||||
return;
|
return;
|
||||||
nread = fread(&buf, 1, sizeof(buf), nfo);
|
nread = fread(&buf, 1, sizeof(buf), nfo);
|
||||||
|
|
||||||
ParseNameValue(buf, nread, &xml);
|
ParseNameValue(buf, nread, &xml, 0);
|
||||||
|
|
||||||
//printf("\ttype: %s\n", GetValueFromNameValueList(&xml, "rootElement"));
|
//printf("\ttype: %s\n", GetValueFromNameValueList(&xml, "rootElement"));
|
||||||
val = GetValueFromNameValueList(&xml, "title");
|
val = GetValueFromNameValueList(&xml, "title");
|
||||||
|
@ -452,7 +452,7 @@ close:
|
|||||||
if( !off )
|
if( !off )
|
||||||
return;
|
return;
|
||||||
nread -= off - buf;
|
nread -= off - buf;
|
||||||
ParseNameValue(off, nread, &xml);
|
ParseNameValue(off, nread, &xml, 0);
|
||||||
model = GetValueFromNameValueList(&xml, "modelName");
|
model = GetValueFromNameValueList(&xml, "modelName");
|
||||||
serial = GetValueFromNameValueList(&xml, "serialNumber");
|
serial = GetValueFromNameValueList(&xml, "serialNumber");
|
||||||
name = GetValueFromNameValueList(&xml, "friendlyName");
|
name = GetValueFromNameValueList(&xml, "friendlyName");
|
||||||
|
@ -30,6 +30,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "minixml.h"
|
#include "minixml.h"
|
||||||
|
#include "upnpreplyparse.h"
|
||||||
|
|
||||||
/* parseatt : used to parse the argument list
|
/* parseatt : used to parse the argument list
|
||||||
* return 0 (false) in case of success and -1 (true) if the end
|
* return 0 (false) in case of success and -1 (true) if the end
|
||||||
@ -152,8 +153,11 @@ void parseelt(struct xmlparser * p)
|
|||||||
if (p->xml >= p->xmlend)
|
if (p->xml >= p->xmlend)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(i>0 && p->datafunc)
|
if (p->datafunc)
|
||||||
p->datafunc(p->data, data, i);
|
{
|
||||||
|
if (i > 0 || (p->flags & XML_STORE_EMPTY_FL))
|
||||||
|
p->datafunc(p->data, data, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(*p->xml == '/')
|
else if(*p->xml == '/')
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef __MINIXML_H__
|
#ifndef __MINIXML_H__
|
||||||
#define __MINIXML_H__
|
#define __MINIXML_H__
|
||||||
|
#include <stdint.h>
|
||||||
#define IS_WHITE_SPACE(c) ((c==' ') || (c=='\t') || (c=='\r') || (c=='\n'))
|
#define IS_WHITE_SPACE(c) ((c==' ') || (c=='\t') || (c=='\r') || (c=='\n'))
|
||||||
|
|
||||||
/* if a callback function pointer is set to NULL,
|
/* if a callback function pointer is set to NULL,
|
||||||
@ -40,6 +41,7 @@ struct xmlparser {
|
|||||||
const char *xmlend;
|
const char *xmlend;
|
||||||
const char *xml; /* pointer to current character */
|
const char *xml; /* pointer to current character */
|
||||||
int xmlsize;
|
int xmlsize;
|
||||||
|
uint32_t flags;
|
||||||
void * data;
|
void * data;
|
||||||
void (*starteltfunc) (void *, const char *, int);
|
void (*starteltfunc) (void *, const char *, int);
|
||||||
void (*endeltfunc) (void *, const char *, int);
|
void (*endeltfunc) (void *, const char *, int);
|
||||||
|
@ -71,7 +71,7 @@ NameValueParserGetData(void * d, const char * datas, int l)
|
|||||||
|
|
||||||
void
|
void
|
||||||
ParseNameValue(const char * buffer, int bufsize,
|
ParseNameValue(const char * buffer, int bufsize,
|
||||||
struct NameValueParserData * data)
|
struct NameValueParserData * data, uint32_t flags)
|
||||||
{
|
{
|
||||||
struct xmlparser parser;
|
struct xmlparser parser;
|
||||||
LIST_INIT(&(data->head));
|
LIST_INIT(&(data->head));
|
||||||
@ -83,6 +83,7 @@ ParseNameValue(const char * buffer, int bufsize,
|
|||||||
parser.endeltfunc = 0;
|
parser.endeltfunc = 0;
|
||||||
parser.datafunc = NameValueParserGetData;
|
parser.datafunc = NameValueParserGetData;
|
||||||
parser.attfunc = 0;
|
parser.attfunc = 0;
|
||||||
|
parser.flags = flags;
|
||||||
parsexml(&parser);
|
parsexml(&parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#ifndef __UPNPREPLYPARSE_H__
|
#ifndef __UPNPREPLYPARSE_H__
|
||||||
#define __UPNPREPLYPARSE_H__
|
#define __UPNPREPLYPARSE_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -46,10 +47,12 @@ struct NameValueParserData {
|
|||||||
char curelt[64];
|
char curelt[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define XML_STORE_EMPTY_FL 0x01
|
||||||
|
|
||||||
/* ParseNameValue() */
|
/* ParseNameValue() */
|
||||||
void
|
void
|
||||||
ParseNameValue(const char * buffer, int bufsize,
|
ParseNameValue(const char * buffer, int bufsize,
|
||||||
struct NameValueParserData * data);
|
struct NameValueParserData * data, uint32_t flags);
|
||||||
|
|
||||||
/* ClearNameValueList() */
|
/* ClearNameValueList() */
|
||||||
void
|
void
|
||||||
|
16
upnpsoap.c
16
upnpsoap.c
@ -138,10 +138,8 @@ IsAuthorizedValidated(struct upnphttp * h, const char * action)
|
|||||||
struct NameValueParserData data;
|
struct NameValueParserData data;
|
||||||
const char * id;
|
const char * id;
|
||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, XML_STORE_EMPTY_FL);
|
||||||
id = GetValueFromNameValueList(&data, "DeviceID");
|
id = GetValueFromNameValueList(&data, "DeviceID");
|
||||||
if (!id)
|
|
||||||
id = strstr(h->req_buf + h->req_contentoff, "<DeviceID>");
|
|
||||||
if(id)
|
if(id)
|
||||||
{
|
{
|
||||||
int bodylen;
|
int bodylen;
|
||||||
@ -270,12 +268,12 @@ GetCurrentConnectionInfo(struct upnphttp * h, const char * action)
|
|||||||
int id;
|
int id;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, XML_STORE_EMPTY_FL);
|
||||||
id_str = GetValueFromNameValueList(&data, "ConnectionID");
|
id_str = GetValueFromNameValueList(&data, "ConnectionID");
|
||||||
DPRINTF(E_INFO, L_HTTP, "GetCurrentConnectionInfo(%s)\n", id_str);
|
DPRINTF(E_INFO, L_HTTP, "GetCurrentConnectionInfo(%s)\n", id_str);
|
||||||
if(id_str)
|
if(id_str)
|
||||||
id = strtol(id_str, &endptr, 10);
|
id = strtol(id_str, &endptr, 10);
|
||||||
if(!id_str || !id_str[0] || !endptr || endptr[0] || id != 0)
|
if (!id_str || endptr == id_str)
|
||||||
{
|
{
|
||||||
SoapError(h, 402, "Invalid Args");
|
SoapError(h, 402, "Invalid Args");
|
||||||
}
|
}
|
||||||
@ -1150,7 +1148,7 @@ BrowseContentDirectory(struct upnphttp * h, const char * action)
|
|||||||
memset(&args, 0, sizeof(args));
|
memset(&args, 0, sizeof(args));
|
||||||
memset(&str, 0, sizeof(str));
|
memset(&str, 0, sizeof(str));
|
||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, 0);
|
||||||
|
|
||||||
ObjectID = GetValueFromNameValueList(&data, "ObjectID");
|
ObjectID = GetValueFromNameValueList(&data, "ObjectID");
|
||||||
Filter = GetValueFromNameValueList(&data, "Filter");
|
Filter = GetValueFromNameValueList(&data, "Filter");
|
||||||
@ -1360,7 +1358,7 @@ SearchContentDirectory(struct upnphttp * h, const char * action)
|
|||||||
memset(&args, 0, sizeof(args));
|
memset(&args, 0, sizeof(args));
|
||||||
memset(&str, 0, sizeof(str));
|
memset(&str, 0, sizeof(str));
|
||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, 0);
|
||||||
|
|
||||||
ContainerID = GetValueFromNameValueList(&data, "ContainerID");
|
ContainerID = GetValueFromNameValueList(&data, "ContainerID");
|
||||||
Filter = GetValueFromNameValueList(&data, "Filter");
|
Filter = GetValueFromNameValueList(&data, "Filter");
|
||||||
@ -1565,7 +1563,7 @@ QueryStateVariable(struct upnphttp * h, const char * action)
|
|||||||
struct NameValueParserData data;
|
struct NameValueParserData data;
|
||||||
const char * var_name;
|
const char * var_name;
|
||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, 0);
|
||||||
/*var_name = GetValueFromNameValueList(&data, "QueryStateVariable"); */
|
/*var_name = GetValueFromNameValueList(&data, "QueryStateVariable"); */
|
||||||
/*var_name = GetValueFromNameValueListIgnoreNS(&data, "varName");*/
|
/*var_name = GetValueFromNameValueListIgnoreNS(&data, "varName");*/
|
||||||
var_name = GetValueFromNameValueList(&data, "varName");
|
var_name = GetValueFromNameValueList(&data, "varName");
|
||||||
@ -1624,7 +1622,7 @@ SamsungSetBookmark(struct upnphttp * h, const char * action)
|
|||||||
struct NameValueParserData data;
|
struct NameValueParserData data;
|
||||||
char *ObjectID, *PosSecond;
|
char *ObjectID, *PosSecond;
|
||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, 0);
|
||||||
ObjectID = GetValueFromNameValueList(&data, "ObjectID");
|
ObjectID = GetValueFromNameValueList(&data, "ObjectID");
|
||||||
PosSecond = GetValueFromNameValueList(&data, "PosSecond");
|
PosSecond = GetValueFromNameValueList(&data, "PosSecond");
|
||||||
if( ObjectID && PosSecond )
|
if( ObjectID && PosSecond )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user