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
340dba4c
Commit
340dba4c
authored
May 01, 2012
by
Mirsal Ennaime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upnp: Cosmetics and variable naming
parent
5eae352d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
66 deletions
+55
-66
modules/services_discovery/upnp.cpp
modules/services_discovery/upnp.cpp
+55
-66
No files found.
modules/services_discovery/upnp.cpp
View file @
340dba4c
...
...
@@ -85,17 +85,17 @@ static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data
const
char
*
xml_getChildElementValue
(
IXML_Element
*
p_parent
,
const
char
*
psz_tag_name
);
const
char
*
xml_getChildElementAttributeValue
(
IXML_Element
*
p_parent
,
const
char
*
psz_tag_name_
,
const
char
*
psz_attribute_
);
const
char
*
xml_getChildElementValue
(
IXML_Document
*
p_doc
,
const
char
*
psz_tag_name
);
IXML_Document
*
parseBrowseResult
(
IXML_Document
*
p_doc
);
const
char
*
xml_getChildElementAttributeValue
(
IXML_Element
*
p_parent
,
const
char
*
psz_tag_name
,
const
char
*
psz_attribute
);
int
parseBrowseNumberValue
(
IXML_Document
*
p_doc
,
const
char
*
psz_tag_name
);
int
xml_getNumber
(
IXML_Document
*
p_doc
,
const
char
*
psz_tag_name
);
IXML_Document
*
parseBrowseResult
(
IXML_Document
*
p_doc
);
/*
* Initializes UPNP instance.
...
...
@@ -180,17 +180,18 @@ static void Close( vlc_object_t *p_this )
* Returns the value of a child element, or NULL on error
*/
const
char
*
xml_getChildElementValue
(
IXML_Element
*
p_parent
,
const
char
*
psz_tag_name
_
)
const
char
*
psz_tag_name
)
{
if
(
!
p_parent
)
return
NULL
;
if
(
!
psz_tag_name_
)
return
NULL
;
if
(
!
p_parent
)
return
NULL
;
if
(
!
psz_tag_name
)
return
NULL
;
IXML_NodeList
*
p_node_list
=
ixmlElement_getElementsByTagName
(
p_parent
,
psz_tag_name_
);
IXML_NodeList
*
p_node_list
;
p_node_list
=
ixmlElement_getElementsByTagName
(
p_parent
,
psz_tag_name
);
if
(
!
p_node_list
)
return
NULL
;
IXML_Node
*
p_element
=
ixmlNodeList_item
(
p_node_list
,
0
);
ixmlNodeList_free
(
p_node_list
);
if
(
!
p_element
)
return
NULL
;
if
(
!
p_element
)
return
NULL
;
IXML_Node
*
p_text_node
=
ixmlNode_getFirstChild
(
p_element
);
if
(
!
p_text_node
)
return
NULL
;
...
...
@@ -202,45 +203,43 @@ const char* xml_getChildElementValue( IXML_Element* p_parent,
* Returns the value of a child element's attribute, or NULL on error
*/
const
char
*
xml_getChildElementAttributeValue
(
IXML_Element
*
p_parent
,
const
char
*
psz_tag_name
_
,
const
char
*
psz_attribute
_
)
const
char
*
psz_tag_name
,
const
char
*
psz_attribute
)
{
if
(
!
p_parent
)
return
NULL
;
if
(
!
psz_tag_name
_
)
return
NULL
;
if
(
!
psz_attribute
_
)
return
NULL
;
if
(
!
p_parent
)
return
NULL
;
if
(
!
psz_tag_name
)
return
NULL
;
if
(
!
psz_attribute
)
return
NULL
;
IXML_NodeList
*
p_node_list
=
ixmlElement_getElementsByTagName
(
p_parent
,
psz_tag_name_
);
if
(
!
p_node_list
)
return
NULL
;
IXML_NodeList
*
p_node_list
;
p_node_list
=
ixmlElement_getElementsByTagName
(
p_parent
,
psz_tag_name
);
if
(
!
p_node_list
)
return
NULL
;
IXML_Node
*
p_element
=
ixmlNodeList_item
(
p_node_list
,
0
);
ixmlNodeList_free
(
p_node_list
);
if
(
!
p_element
)
return
NULL
;
if
(
!
p_element
)
return
NULL
;
return
ixmlElement_getAttribute
(
(
IXML_Element
*
)
p_element
,
psz_attribute
_
);
return
ixmlElement_getAttribute
(
(
IXML_Element
*
)
p_element
,
psz_attribute
);
}
/*
* Returns the value of a child element, or NULL on error
*/
const
char
*
xml_getChildElementValue
(
IXML_Document
*
p_doc
,
const
char
*
psz_tag_name
_
)
const
char
*
psz_tag_name
)
{
if
(
!
p_doc
)
return
0
;
if
(
!
psz_tag_name_
)
return
0
;
IXML_NodeList
*
p_result_list
=
ixmlDocument_getElementsByTagName
(
p_doc
,
psz_tag_name_
);
if
(
!
p_doc
)
return
NULL
;
if
(
!
psz_tag_name
)
return
NULL
;
if
(
!
p_result_list
)
return
0
;
IXML_NodeList
*
p_node_list
;
p_node_list
=
ixmlDocument_getElementsByTagName
(
p_doc
,
psz_tag_name
);
if
(
!
p_node_list
)
return
NULL
;
IXML_Node
*
p_result_node
=
ixmlNodeList_item
(
p_result_list
,
0
);
ixmlNodeList_free
(
p_result_list
);
if
(
!
p_result_node
)
return
0
;
IXML_Node
*
p_element
=
ixmlNodeList_item
(
p_node_list
,
0
);
ixmlNodeList_free
(
p_node_list
);
if
(
!
p_element
)
return
NULL
;
IXML_Node
*
p_text_node
=
ixmlNode_getFirstChild
(
p_
result_node
);
if
(
!
p_text_node
)
return
0
;
IXML_Node
*
p_text_node
=
ixmlNode_getFirstChild
(
p_
element
);
if
(
!
p_text_node
)
return
NULL
;
return
ixmlNode_getNodeValue
(
p_text_node
);
}
...
...
@@ -263,25 +262,21 @@ IXML_Document* parseBrowseResult( IXML_Document* p_doc )
/*
* Get the number value from a SOAP response
*/
int
parseBrowseNumberValue
(
IXML_Document
*
p_doc
,
const
char
*
psz_tag_name_
)
int
xml_getNumber
(
IXML_Document
*
p_doc
,
const
char
*
psz_tag_name
)
{
ixmlRelaxParser
(
1
);
const
char
*
psz_number_string
=
xml_getChildElementValue
(
p_doc
,
psz_tag_name_
);
if
(
!
psz_number_string
)
return
0
;
const
char
*
psz
=
xml_getChildElementValue
(
p_doc
,
psz_tag_name
);
if
(
!
psz
)
return
0
;
char
*
psz_end
;
long
l
=
strtol
(
psz_number_string
,
&
psz_end
,
10
);
long
l
=
strtol
(
psz
,
&
psz_end
,
10
);
if
(
*
psz_end
||
l
<
0
||
l
>
INT_MAX
)
{
return
0
;
}
else
{
return
(
int
)
l
;
}
return
(
int
)
l
;
}
/*
...
...
@@ -760,7 +755,7 @@ void MediaServer::fetchContents()
/*
* Fetches and parses the UPNP response
*/
bool
MediaServer
::
_fetchContents
(
Container
*
p_parent
,
int
i_
starting_index
)
bool
MediaServer
::
_fetchContents
(
Container
*
p_parent
,
int
i_
offset
)
{
if
(
!
p_parent
)
{
...
...
@@ -769,9 +764,9 @@ bool MediaServer::_fetchContents( Container* p_parent, int i_starting_index )
}
char
*
psz_starting_index
;
if
(
asprintf
(
&
psz_starting_index
,
"%d"
,
i_
starting_index
)
<
0
)
if
(
asprintf
(
&
psz_starting_index
,
"%d"
,
i_
offset
)
<
0
)
{
msg_Err
(
_p_sd
,
"asprintf error:%d"
,
i_
starting_index
);
msg_Err
(
_p_sd
,
"asprintf error:%d"
,
i_
offset
);
return
false
;
}
...
...
@@ -790,12 +785,14 @@ bool MediaServer::_fetchContents( Container* p_parent, int i_starting_index )
}
IXML_Document
*
p_result
=
parseBrowseResult
(
p_response
);
int
i_number_returned
=
parseBrowseNumberValue
(
p_response
,
"NumberReturned"
);
int
i_total_matches
=
parseBrowseNumberValue
(
p_response
,
"TotalMatches"
);
int
i_number_returned
=
xml_getNumber
(
p_response
,
"NumberReturned"
);
int
i_total_matches
=
xml_getNumber
(
p_response
,
"TotalMatches"
);
#ifndef NDEBUG
msg_Dbg
(
_p_sd
,
"i_
starting_index
[%d]i_number_returned[%d]_total_matches[%d]
\n
"
,
i_
starting_index
,
i_number_returned
,
i_total_matches
);
msg_Dbg
(
_p_sd
,
"i_
offset
[%d]i_number_returned[%d]_total_matches[%d]
\n
"
,
i_
offset
,
i_number_returned
,
i_total_matches
);
#endif
ixmlDocument_free
(
p_response
);
if
(
!
p_result
)
...
...
@@ -803,12 +800,9 @@ bool MediaServer::_fetchContents( Container* p_parent, int i_starting_index )
msg_Err
(
_p_sd
,
"browse() response parsing failed"
);
return
false
;
}
#ifndef NDEBUG
else
{
msg_Dbg
(
_p_sd
,
"Got DIDL document: %s"
,
ixmlPrintDocument
(
p_result
)
);
}
msg_Dbg
(
_p_sd
,
"Got DIDL document: %s"
,
ixmlPrintDocument
(
p_result
)
);
#endif
IXML_NodeList
*
containerNodeList
=
...
...
@@ -892,13 +886,8 @@ bool MediaServer::_fetchContents( Container* p_parent, int i_starting_index )
ixmlDocument_free
(
p_result
);
if
(
i_starting_index
+
i_number_returned
<
i_total_matches
)
{
if
(
!
_fetchContents
(
p_parent
,
i_starting_index
+
i_number_returned
)
)
{
return
false
;
}
}
if
(
i_offset
+
i_number_returned
<
i_total_matches
)
return
_fetchContents
(
p_parent
,
i_offset
+
i_number_returned
);
return
true
;
}
...
...
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