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
b999e164
Commit
b999e164
authored
Apr 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongFilter: convert argv to ConstBuffer
parent
7fb9bebd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
13 deletions
+27
-13
SongFilter.cxx
src/SongFilter.cxx
+5
-4
SongFilter.hxx
src/SongFilter.hxx
+2
-2
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+16
-6
QueueCommands.cxx
src/command/QueueCommands.cxx
+4
-1
No files found.
src/SongFilter.cxx
View file @
b999e164
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "db/LightSong.hxx"
#include "db/LightSong.hxx"
#include "DetachedSong.hxx"
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ASCII.hxx"
#include "util/ASCII.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "lib/icu/Collate.hxx"
#include "lib/icu/Collate.hxx"
...
@@ -181,13 +182,13 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case)
...
@@ -181,13 +182,13 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case)
}
}
bool
bool
SongFilter
::
Parse
(
unsigned
argc
,
char
*
argv
[]
,
bool
fold_case
)
SongFilter
::
Parse
(
ConstBuffer
<
const
char
*>
args
,
bool
fold_case
)
{
{
if
(
arg
c
==
0
||
argc
%
2
!=
0
)
if
(
arg
s
.
size
==
0
||
args
.
size
%
2
!=
0
)
return
false
;
return
false
;
for
(
unsigned
i
=
0
;
i
<
arg
c
;
i
+=
2
)
for
(
unsigned
i
=
0
;
i
<
arg
s
.
size
;
i
+=
2
)
if
(
!
Parse
(
arg
v
[
i
],
argv
[
i
+
1
],
fold_case
))
if
(
!
Parse
(
arg
s
[
i
],
args
[
i
+
1
],
fold_case
))
return
false
;
return
false
;
return
true
;
return
true
;
...
...
src/SongFilter.hxx
View file @
b999e164
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#define LOCATE_TAG_FILE_TYPE TAG_NUM_OF_ITEM_TYPES+10
#define LOCATE_TAG_FILE_TYPE TAG_NUM_OF_ITEM_TYPES+10
#define LOCATE_TAG_ANY_TYPE TAG_NUM_OF_ITEM_TYPES+20
#define LOCATE_TAG_ANY_TYPE TAG_NUM_OF_ITEM_TYPES+20
template
<
typename
T
>
struct
ConstBuffer
;
struct
Tag
;
struct
Tag
;
struct
TagItem
;
struct
TagItem
;
struct
Song
;
struct
Song
;
...
@@ -101,8 +102,7 @@ public:
...
@@ -101,8 +102,7 @@ public:
gcc_nonnull
(
2
,
3
)
gcc_nonnull
(
2
,
3
)
bool
Parse
(
const
char
*
tag
,
const
char
*
value
,
bool
fold_case
=
false
);
bool
Parse
(
const
char
*
tag
,
const
char
*
value
,
bool
fold_case
=
false
);
gcc_nonnull
(
3
)
bool
Parse
(
ConstBuffer
<
const
char
*>
args
,
bool
fold_case
=
false
);
bool
Parse
(
unsigned
argc
,
char
*
argv
[],
bool
fold_case
=
false
);
gcc_pure
gcc_pure
bool
Match
(
const
Tag
&
tag
)
const
;
bool
Match
(
const
Tag
&
tag
)
const
;
...
...
src/command/DatabaseCommands.cxx
View file @
b999e164
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "CommandError.hxx"
#include "CommandError.hxx"
#include "client/Client.hxx"
#include "client/Client.hxx"
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "SongFilter.hxx"
#include "SongFilter.hxx"
#include "protocol/Result.hxx"
#include "protocol/Result.hxx"
...
@@ -63,8 +64,10 @@ handle_lsinfo2(Client &client, int argc, char *argv[])
...
@@ -63,8 +64,10 @@ handle_lsinfo2(Client &client, int argc, char *argv[])
static
CommandResult
static
CommandResult
handle_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
handle_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
{
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
arg
c
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
arg
s
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -92,8 +95,10 @@ handle_search(Client &client, int argc, char *argv[])
...
@@ -92,8 +95,10 @@ handle_search(Client &client, int argc, char *argv[])
static
CommandResult
static
CommandResult
handle_match_add
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
handle_match_add
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
{
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
arg
c
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
arg
s
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -120,10 +125,11 @@ handle_searchadd(Client &client, int argc, char *argv[])
...
@@ -120,10 +125,11 @@ handle_searchadd(Client &client, int argc, char *argv[])
CommandResult
CommandResult
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
playlist
=
argv
[
1
];
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
const
char
*
playlist
=
args
.
shift
();
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
arg
c
-
2
,
argv
+
2
,
true
))
{
if
(
!
filter
.
Parse
(
arg
s
,
true
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -142,8 +148,10 @@ handle_searchaddpl(Client &client, int argc, char *argv[])
...
@@ -142,8 +148,10 @@ handle_searchaddpl(Client &client, int argc, char *argv[])
CommandResult
CommandResult
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[])
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
arg
c
-
1
,
argv
+
1
,
false
))
{
if
(
!
filter
.
Parse
(
arg
s
,
false
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -191,8 +199,10 @@ handle_list(Client &client, int argc, char *argv[])
...
@@ -191,8 +199,10 @@ handle_list(Client &client, int argc, char *argv[])
filter
=
new
SongFilter
((
unsigned
)
TAG_ARTIST
,
argv
[
2
]);
filter
=
new
SongFilter
((
unsigned
)
TAG_ARTIST
,
argv
[
2
]);
}
else
if
(
argc
>
2
)
{
}
else
if
(
argc
>
2
)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
2
,
argc
-
2
);
filter
=
new
SongFilter
();
filter
=
new
SongFilter
();
if
(
!
filter
->
Parse
(
arg
c
-
2
,
argv
+
2
,
false
))
{
if
(
!
filter
->
Parse
(
arg
s
,
false
))
{
delete
filter
;
delete
filter
;
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"not able to parse args"
);
"not able to parse args"
);
...
...
src/command/QueueCommands.cxx
View file @
b999e164
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "protocol/ArgParser.hxx"
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "ls.hxx"
#include "util/ConstBuffer.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/AllocatedPath.hxx"
...
@@ -231,8 +232,10 @@ static CommandResult
...
@@ -231,8 +232,10 @@ static CommandResult
handle_playlist_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
handle_playlist_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
bool
fold_case
)
{
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
arg
c
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
arg
s
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
...
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