Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8add78ed
Commit
8add78ed
authored
Jan 11, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp/discovery: convert std::strings to const char *
Reduce bloat.
parent
4b3a3d6f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
Discovery.cxx
src/db/upnp/Discovery.cxx
+13
-11
No files found.
src/db/upnp/Discovery.cxx
View file @
8add78ed
...
...
@@ -34,25 +34,27 @@
#include <map>
// The service type string we are looking for.
static
const
std
::
string
ContentDirectorySType
(
"urn:schemas-upnp-org:service:ContentDirectory:1"
)
;
static
const
char
*
const
ContentDirectorySType
=
"urn:schemas-upnp-org:service:ContentDirectory:1"
;
// We don't include a version in comparisons, as we are satisfied with
// version 1
gcc_pure
static
bool
isCDService
(
const
std
::
string
&
st
)
isCDService
(
const
char
*
st
)
{
const
s
td
::
string
::
size_type
sz
(
ContentDirectorySType
.
size
()
-
2
)
;
return
!
ContentDirectorySType
.
compare
(
0
,
sz
,
st
,
0
,
sz
)
;
const
s
ize_t
sz
=
strlen
(
ContentDirectorySType
)
-
2
;
return
memcmp
(
ContentDirectorySType
,
st
,
sz
)
==
0
;
}
// The type of device we're asking for in search
static
const
std
::
string
MediaServerDType
(
"urn:schemas-upnp-org:device:MediaServer:1"
)
;
static
const
char
*
const
MediaServerDType
=
"urn:schemas-upnp-org:device:MediaServer:1"
;
gcc_pure
static
bool
isMSDevice
(
const
std
::
string
&
st
)
isMSDevice
(
const
char
*
st
)
{
const
s
td
::
string
::
size_type
sz
(
MediaServerDType
.
size
()
-
2
)
;
return
!
MediaServerDType
.
compare
(
0
,
sz
,
st
,
0
,
sz
)
;
const
s
ize_t
sz
=
strlen
(
MediaServerDType
)
-
2
;
return
memcmp
(
MediaServerDType
,
st
,
sz
)
==
0
;
}
/**
...
...
@@ -252,7 +254,7 @@ UPnPDeviceDirectory::search()
// We search both for device and service just in case.
int
code
=
UpnpSearchAsync
(
lib
->
getclh
(),
m_searchTimeout
,
ContentDirectorySType
.
c_str
()
,
lib
);
ContentDirectorySType
,
lib
);
if
(
code
!=
UPNP_E_SUCCESS
)
{
error
.
Format
(
upnp_domain
,
code
,
"UpnpSearchAsync() failed: %s"
,
...
...
@@ -261,7 +263,7 @@ UPnPDeviceDirectory::search()
}
code
=
UpnpSearchAsync
(
lib
->
getclh
(),
m_searchTimeout
,
MediaServerDType
.
c_str
()
,
lib
);
MediaServerDType
,
lib
);
if
(
code
!=
UPNP_E_SUCCESS
)
{
error
.
Format
(
upnp_domain
,
code
,
"UpnpSearchAsync() failed: %s"
,
...
...
@@ -297,7 +299,7 @@ UPnPDeviceDirectory::getDirServices(std::vector<ContentDirectoryService> &out)
for
(
auto
dit
=
contentDirectories
.
m_directories
.
begin
();
dit
!=
contentDirectories
.
m_directories
.
end
();
dit
++
)
{
for
(
const
auto
&
service
:
dit
->
second
.
device
.
services
)
{
if
(
isCDService
(
service
.
serviceType
))
{
if
(
isCDService
(
service
.
serviceType
.
c_str
()
))
{
out
.
emplace_back
(
dit
->
second
.
device
,
service
);
}
}
...
...
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