Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Icecast-Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ralph Giles
Icecast-Server
Commits
36ff987e
Commit
36ff987e
authored
4 years ago
by
Philipp Schafft
Browse files
Options
Downloads
Patches
Plain Diff
Feature: Unified node identification in a single function
parent
cc13aba1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xml2json.c
+19
-6
19 additions, 6 deletions
src/xml2json.c
with
19 additions
and
6 deletions
src/xml2json.c
+
19
−
6
View file @
36ff987e
...
...
@@ -99,6 +99,24 @@ static int nodelist_is_empty(struct nodelist *list)
return
1
;
}
static
void
handle_node_identification
(
json_renderer_t
*
renderer
,
const
char
*
name
,
const
char
*
ns
,
const
char
*
id
)
{
json_renderer_begin
(
renderer
,
JSON_ELEMENT_TYPE_OBJECT
);
if
(
name
)
{
json_renderer_write_key
(
renderer
,
"name"
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_write_string
(
renderer
,
name
,
JSON_RENDERER_FLAGS_NONE
);
}
if
(
ns
)
{
json_renderer_write_key
(
renderer
,
"ns"
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_write_string
(
renderer
,
ns
,
JSON_RENDERER_FLAGS_NONE
);
}
if
(
id
)
{
json_renderer_write_key
(
renderer
,
"id"
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_write_string
(
renderer
,
id
,
JSON_RENDERER_FLAGS_NONE
);
}
json_renderer_end
(
renderer
);
}
static
void
handle_textchildnode
(
json_renderer_t
*
renderer
,
xmlDocPtr
doc
,
xmlNodePtr
node
,
xmlNodePtr
parent
,
struct
xml2json_cache
*
cache
)
{
xmlChar
*
value
=
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
...
...
@@ -305,12 +323,7 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm
if
(
is_icestats
)
{
json_renderer_begin
(
renderer
,
JSON_ELEMENT_TYPE_ARRAY
);
json_renderer_begin
(
renderer
,
JSON_ELEMENT_TYPE_OBJECT
);
json_renderer_write_key
(
renderer
,
"name"
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_write_string
(
renderer
,
"icestats"
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_write_key
(
renderer
,
"ns"
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_write_string
(
renderer
,
XMLNS_LEGACY_STATS
,
JSON_RENDERER_FLAGS_NONE
);
json_renderer_end
(
renderer
);
handle_node_identification
(
renderer
,
"icestats"
,
XMLNS_LEGACY_STATS
,
NULL
);
}
json_renderer_begin
(
renderer
,
JSON_ELEMENT_TYPE_OBJECT
);
if
(
node
->
xmlChildrenNode
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment