Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
70f70fd0
Commit
70f70fd0
authored
Apr 01, 2005
by
Sigmund Augdal Helberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: ported xml parsers to stream_t
parent
2cdb935b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
24 deletions
+40
-24
include/vlc_xml.h
include/vlc_xml.h
+1
-1
modules/gui/skins2/parser/xmlparser.cpp
modules/gui/skins2/parser/xmlparser.cpp
+12
-2
modules/gui/skins2/parser/xmlparser.hpp
modules/gui/skins2/parser/xmlparser.hpp
+3
-0
modules/misc/xml/libxml.c
modules/misc/xml/libxml.c
+15
-4
modules/misc/xml/xtag.c
modules/misc/xml/xtag.c
+9
-17
No files found.
include/vlc_xml.h
View file @
70f70fd0
...
...
@@ -36,7 +36,7 @@ struct xml_t
module_t
*
p_module
;
xml_sys_t
*
p_sys
;
xml_reader_t
*
(
*
pf_reader_create
)
(
xml_t
*
,
const
char
*
);
xml_reader_t
*
(
*
pf_reader_create
)
(
xml_t
*
,
stream_t
*
);
void
(
*
pf_reader_delete
)
(
xml_reader_t
*
);
void
(
*
pf_catalog_load
)
(
xml_t
*
,
const
char
*
);
...
...
modules/gui/skins2/parser/xmlparser.cpp
View file @
70f70fd0
...
...
@@ -32,11 +32,13 @@ static bool m_initialized = false;
XMLParser
::
XMLParser
(
intf_thread_t
*
pIntf
,
const
string
&
rFileName
)
:
SkinObject
(
pIntf
)
{
m_pReader
=
NULL
;
m_pStream
=
NULL
;
m_pXML
=
xml_Create
(
pIntf
);
if
(
!
m_pXML
)
{
msg_Err
(
getIntf
(),
"Failed to open XML parser"
);
m_pReader
=
NULL
;
return
;
}
...
...
@@ -47,7 +49,14 @@ XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
m_initialized
=
true
;
}
m_pReader
=
xml_ReaderCreate
(
m_pXML
,
rFileName
.
c_str
()
);
m_pStream
=
stream_UrlNew
(
pIntf
,
rFileName
.
c_str
()
);
if
(
!
m_pStream
)
{
msg_Err
(
getIntf
(),
"Failed to open %s for reading"
,
rFileName
.
c_str
()
);
return
;
}
m_pReader
=
xml_ReaderCreate
(
m_pXML
,
m_pStream
);
if
(
!
m_pReader
)
{
msg_Err
(
getIntf
(),
"Failed to open %s for parsing"
,
...
...
@@ -61,6 +70,7 @@ XMLParser::~XMLParser()
{
if
(
m_pReader
&&
m_pXML
)
xml_ReaderDelete
(
m_pXML
,
m_pReader
);
if
(
m_pXML
)
xml_Delete
(
m_pXML
);
if
(
m_pStream
)
stream_Delete
(
m_pStream
);
}
...
...
modules/gui/skins2/parser/xmlparser.hpp
View file @
70f70fd0
...
...
@@ -25,6 +25,8 @@
#define XMLPARSER_HPP
#include "../src/skin_common.hpp"
#include "vlc_block.h"
#include "vlc_stream.h"
#include "vlc_xml.h"
#include <map>
...
...
@@ -67,6 +69,7 @@ class XMLParser: public SkinObject
/// Reader context
xml_t
*
m_pXML
;
xml_reader_t
*
m_pReader
;
stream_t
*
m_pStream
;
};
#endif
modules/misc/xml/libxml.c
View file @
70f70fd0
...
...
@@ -49,7 +49,7 @@ struct xml_reader_sys_t
xmlTextReaderPtr
p_reader
;
};
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
,
const
char
*
);
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
,
stream_t
*
);
static
void
ReaderDelete
(
xml_reader_t
*
);
static
int
ReaderRead
(
xml_reader_t
*
);
static
int
ReaderNodeType
(
xml_reader_t
*
);
...
...
@@ -59,6 +59,7 @@ static int ReaderNextAttr( xml_reader_t * );
static
void
CatalogLoad
(
xml_t
*
,
const
char
*
);
static
void
CatalogAdd
(
xml_t
*
,
const
char
*
,
const
char
*
,
const
char
*
);
static
int
StreamRead
(
void
*
p_context
,
char
*
p_buffer
,
int
i_buffer
);
/*****************************************************************************
* Module initialization
...
...
@@ -111,16 +112,20 @@ static void ReaderErrorHandler( void *p_arg, const char *p_msg,
msg_Err
(
p_reader
->
p_xml
,
"XML parser error (line %d) : %s"
,
line
,
p_msg
);
}
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
p_xml
,
const
char
*
psz_filename
)
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
p_xml
,
stream_t
*
p_stream
)
{
xml_reader_t
*
p_reader
;
xml_reader_sys_t
*
p_sys
;
xmlTextReaderPtr
p_libxml_reader
;
xmlParserInputBufferPtr
p_read_context
;
p_libxml_reader
=
xmlNewTextReaderFilename
(
psz_filename
);
p_read_context
=
malloc
(
sizeof
(
xmlParserInputBuffer
)
);
p_libxml_reader
=
xmlReaderForIO
(
StreamRead
,
NULL
,
p_stream
,
NULL
,
NULL
,
0
);
if
(
!
p_libxml_reader
)
{
msg_Err
(
p_xml
,
"failed to
open file %s for parsing"
,
psz_filename
);
msg_Err
(
p_xml
,
"failed to
create xml parser"
);
return
0
;
}
...
...
@@ -214,3 +219,9 @@ static int ReaderNextAttr( xml_reader_t *p_reader )
return
(
xmlTextReaderMoveToNextAttribute
(
p_reader
->
p_sys
->
p_reader
)
==
1
)
?
VLC_SUCCESS
:
VLC_EGENERIC
;
}
static
int
StreamRead
(
void
*
p_context
,
char
*
p_buffer
,
int
i_buffer
)
{
stream_t
*
s
=
(
stream_t
*
)
p_context
;
return
stream_Read
(
s
,
p_buffer
,
i_buffer
);
}
modules/misc/xml/xtag.c
View file @
70f70fd0
...
...
@@ -30,6 +30,8 @@
#include <vlc/vlc.h>
#include "vlc_xml.h"
#include "vlc_block.h"
#include "vlc_stream.h"
#include <ctype.h>
#include <string.h>
...
...
@@ -98,7 +100,7 @@ struct xml_reader_sys_t
vlc_bool_t
b_endtag
;
};
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
,
const
char
*
);
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
,
stream_t
*
);
static
void
ReaderDelete
(
xml_reader_t
*
);
static
int
ReaderRead
(
xml_reader_t
*
);
static
int
ReaderNodeType
(
xml_reader_t
*
);
...
...
@@ -158,34 +160,24 @@ static void CatalogAdd( xml_t *p_xml, const char *psz_arg1,
/*****************************************************************************
* Reader functions
*****************************************************************************/
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
p_xml
,
const
char
*
psz_filename
)
static
xml_reader_t
*
ReaderCreate
(
xml_t
*
p_xml
,
stream_t
*
s
)
{
xml_reader_t
*
p_reader
;
xml_reader_sys_t
*
p_sys
;
char
*
p_buffer
;
int
i_buffer
;
FILE
*
file
;
XTag
*
p_root
;
/* Open and read file */
file
=
fopen
(
psz_filename
,
"rt"
);
if
(
!
file
)
{
msg_Warn
(
p_xml
,
"could not open file '%s'"
,
psz_filename
);
return
0
;
}
fseek
(
file
,
0L
,
SEEK_END
);
i_buffer
=
ftell
(
file
);
fseek
(
file
,
0L
,
SEEK_SET
);
i_buffer
=
stream_Size
(
s
);
p_buffer
=
malloc
(
i_buffer
+
1
);
i_buffer
=
fread
(
p_buffer
,
1
,
i_buffer
,
file
);
p_buffer
[
i_buffer
]
=
0
;
fclose
(
file
);
i_buffer
=
stream_Read
(
s
,
p_buffer
,
i_buffer
);
p_buffer
[
i_buffer
]
=
0
;
if
(
!
i_buffer
)
{
msg_Dbg
(
p_xml
,
"
file '%s' is empty"
,
psz_filename
);
msg_Dbg
(
p_xml
,
"
empty xml"
);
free
(
p_buffer
);
return
0
;
}
...
...
@@ -193,7 +185,7 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, const char *psz_filename )
p_root
=
xtag_new_parse
(
p_buffer
,
i_buffer
);
if
(
!
p_root
)
{
msg_Warn
(
p_xml
,
"couldn't parse
file '%s'"
,
psz_filename
);
msg_Warn
(
p_xml
,
"couldn't parse
xml"
);
free
(
p_buffer
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment