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
6a2118d0
Commit
6a2118d0
authored
Jan 24, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue_print, dbUtils: use struct locate_item_list
Changed the function prototypes to get locate_item_list objects instead of num_items/items.
parent
ba7c9962
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
74 deletions
+58
-74
command.c
src/command.c
+6
-7
dbUtils.c
src/dbUtils.c
+21
-39
dbUtils.h
src/dbUtils.h
+6
-6
locate.c
src/locate.c
+10
-8
locate.h
src/locate.h
+4
-4
queue_print.c
src/queue_print.c
+8
-7
queue_print.h
src/queue_print.h
+3
-3
No files found.
src/command.c
View file @
6a2118d0
...
...
@@ -844,7 +844,7 @@ handle_find(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
ret
=
findSongsIn
(
client
,
NULL
,
list
->
length
,
list
->
items
);
ret
=
findSongsIn
(
client
,
NULL
,
list
);
if
(
ret
==
-
1
)
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
...
...
@@ -869,7 +869,7 @@ handle_search(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
ret
=
searchForSongsIn
(
client
,
NULL
,
list
->
length
,
list
->
items
);
ret
=
searchForSongsIn
(
client
,
NULL
,
list
);
if
(
ret
==
-
1
)
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
...
...
@@ -894,7 +894,7 @@ handle_count(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
ret
=
searchStatsForSongsIn
(
client
,
NULL
,
list
->
length
,
list
->
items
);
ret
=
searchStatsForSongsIn
(
client
,
NULL
,
list
);
if
(
ret
==
-
1
)
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
...
...
@@ -918,7 +918,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
queue_find
(
client
,
playlist_get_queue
(),
list
->
length
,
list
->
items
);
queue_find
(
client
,
playlist_get_queue
(),
list
);
locate_item_list_free
(
list
);
...
...
@@ -939,7 +939,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
queue_search
(
client
,
playlist_get_queue
(),
list
->
length
,
list
->
items
);
queue_search
(
client
,
playlist_get_queue
(),
list
);
locate_item_list_free
(
list
);
...
...
@@ -1155,8 +1155,7 @@ handle_list(struct client *client, int argc, char *argv[])
}
}
ret
=
listAllUniqueTags
(
client
,
tagType
,
conditionals
->
length
,
conditionals
->
items
);
ret
=
listAllUniqueTags
(
client
,
tagType
,
conditionals
);
locate_item_list_free
(
conditionals
);
...
...
src/dbUtils.c
View file @
6a2118d0
...
...
@@ -35,17 +35,11 @@
typedef
struct
_ListCommandItem
{
int8_t
tagType
;
int
numConditionals
;
const
struct
locate_item
*
conditionals
;
const
struct
locate_item_list
*
criteria
;
}
ListCommandItem
;
typedef
struct
_LocateTagItemArray
{
int
numItems
;
const
struct
locate_item
*
items
;
}
LocateTagItemArray
;
typedef
struct
_SearchStats
{
LocateTagItemArray
locateArray
;
const
struct
locate_item_list
*
criteria
;
int
numberOfSongs
;
unsigned
long
playTime
;
}
SearchStats
;
...
...
@@ -71,16 +65,15 @@ printSongInDirectory(struct song *song, G_GNUC_UNUSED void *data)
struct
search_data
{
struct
client
*
client
;
LocateTagItemArray
array
;
const
struct
locate_item_list
*
criteria
;
};
static
int
searchInDirectory
(
struct
song
*
song
,
void
*
_data
)
{
struct
search_data
*
data
=
_data
;
LocateTagItemArray
*
array
=
&
data
->
array
;
if
(
locate_song_search
(
song
,
array
->
numItems
,
array
->
items
))
if
(
locate_song_search
(
song
,
data
->
criteria
))
return
song_print_info
(
data
->
client
,
song
);
return
0
;
...
...
@@ -88,21 +81,19 @@ searchInDirectory(struct song *song, void *_data)
int
searchForSongsIn
(
struct
client
*
client
,
const
char
*
name
,
int
numItems
,
const
struct
locate_item
*
items
)
const
struct
locate_item_list
*
criteria
)
{
int
ret
;
int
i
;
struct
locate_item_list
*
new_list
;
struct
search_data
data
;
new_list
=
locate_item_list_new
(
numItems
);
for
(
i
=
0
;
i
<
numItems
;
i
++
)
new_list
=
locate_item_list_new
(
criteria
->
length
);
for
(
unsigned
i
=
0
;
i
<
criteria
->
length
;
i
++
)
new_list
->
items
[
i
].
needle
=
g_utf8_casefold
(
items
[
i
].
needle
,
-
1
);
g_utf8_casefold
(
criteria
->
items
[
i
].
needle
,
-
1
);
data
.
client
=
client
;
data
.
array
.
numItems
=
numItems
;
data
.
array
.
items
=
new_list
->
items
;
data
.
criteria
=
new_list
;
ret
=
db_walk
(
name
,
searchInDirectory
,
NULL
,
&
data
);
...
...
@@ -115,9 +106,8 @@ static int
findInDirectory
(
struct
song
*
song
,
void
*
_data
)
{
struct
search_data
*
data
=
_data
;
LocateTagItemArray
*
array
=
&
data
->
array
;
if
(
locate_song_match
(
song
,
array
->
numItems
,
array
->
items
))
if
(
locate_song_match
(
song
,
data
->
criteria
))
return
song_print_info
(
data
->
client
,
song
);
return
0
;
...
...
@@ -125,13 +115,12 @@ findInDirectory(struct song *song, void *_data)
int
findSongsIn
(
struct
client
*
client
,
const
char
*
name
,
int
numItems
,
const
struct
locate_item
*
items
)
const
struct
locate_item_list
*
criteria
)
{
struct
search_data
data
;
data
.
client
=
client
;
data
.
array
.
numItems
=
numItems
;
data
.
array
.
items
=
items
;
data
.
criteria
=
criteria
;
return
db_walk
(
name
,
findInDirectory
,
NULL
,
&
data
);
}
...
...
@@ -147,8 +136,7 @@ searchStatsInDirectory(struct song *song, void *data)
{
SearchStats
*
stats
=
data
;
if
(
locate_song_match
(
song
,
stats
->
locateArray
.
numItems
,
stats
->
locateArray
.
items
))
{
if
(
locate_song_match
(
song
,
stats
->
criteria
))
{
stats
->
numberOfSongs
++
;
if
(
song
->
tag
->
time
>
0
)
stats
->
playTime
+=
song
->
tag
->
time
;
...
...
@@ -159,13 +147,12 @@ searchStatsInDirectory(struct song *song, void *data)
int
searchStatsForSongsIn
(
struct
client
*
client
,
const
char
*
name
,
int
numItems
,
const
struct
locate_item
*
items
)
const
struct
locate_item_list
*
criteria
)
{
SearchStats
stats
;
int
ret
;
stats
.
locateArray
.
numItems
=
numItems
;
stats
.
locateArray
.
items
=
items
;
stats
.
criteria
=
criteria
;
stats
.
numberOfSongs
=
0
;
stats
.
playTime
=
0
;
...
...
@@ -231,14 +218,12 @@ int printInfoForAllIn(struct client *client, const char *name)
}
static
ListCommandItem
*
newListCommandItem
(
int
tagType
,
int
numConditionals
,
const
struct
locate_item
*
conditionals
)
newListCommandItem
(
int
tagType
,
const
struct
locate_item_list
*
criteria
)
{
ListCommandItem
*
item
=
g_new
(
ListCommandItem
,
1
);
item
->
tagType
=
tagType
;
item
->
numConditionals
=
numConditionals
;
item
->
conditionals
=
conditionals
;
item
->
criteria
=
criteria
;
return
item
;
}
...
...
@@ -284,20 +269,17 @@ listUniqueTagsInDirectory(struct song *song, void *_data)
struct
list_tags_data
*
data
=
_data
;
ListCommandItem
*
item
=
data
->
item
;
if
(
locate_song_match
(
song
,
item
->
numConditionals
,
item
->
conditionals
))
{
if
(
locate_song_match
(
song
,
item
->
criteria
))
visitTag
(
data
->
client
,
data
->
set
,
song
,
item
->
tagType
);
}
return
0
;
}
int
listAllUniqueTags
(
struct
client
*
client
,
int
type
,
int
numConditionals
,
const
struct
locate_item
*
conditionals
)
int
listAllUniqueTags
(
struct
client
*
client
,
int
type
,
const
struct
locate_item
_list
*
criteria
)
{
int
ret
;
ListCommandItem
*
item
=
newListCommandItem
(
type
,
numConditionals
,
conditionals
);
ListCommandItem
*
item
=
newListCommandItem
(
type
,
criteria
);
struct
list_tags_data
data
=
{
.
client
=
client
,
.
item
=
item
,
...
...
src/dbUtils.h
View file @
6a2118d0
...
...
@@ -20,7 +20,7 @@
#define MPD_DB_UTILS_H
struct
client
;
struct
locate_item
;
struct
locate_item
_list
;
int
printAllIn
(
struct
client
*
client
,
const
char
*
name
);
...
...
@@ -32,21 +32,21 @@ int printInfoForAllIn(struct client *client, const char *name);
int
searchForSongsIn
(
struct
client
*
client
,
const
char
*
name
,
int
numItems
,
const
struct
locate_item
*
items
);
const
struct
locate_item_list
*
criteria
);
int
findSongsIn
(
struct
client
*
client
,
const
char
*
name
,
int
numItems
,
const
struct
locate_item
*
items
);
const
struct
locate_item_list
*
criteria
);
int
searchStatsForSongsIn
(
struct
client
*
client
,
const
char
*
name
,
int
numItems
,
const
struct
locate_item
*
items
);
const
struct
locate_item_list
*
criteria
);
unsigned
long
sumSongTimesIn
(
const
char
*
name
);
int
listAllUniqueTags
(
struct
client
*
client
,
int
type
,
int
numConditiionals
,
const
struct
locate_item
*
conditionals
);
listAllUniqueTags
(
struct
client
*
client
,
int
type
,
const
struct
locate_item
_list
*
criteria
);
void
printSavedMemoryFromFilenames
(
void
);
...
...
src/locate.c
View file @
6a2118d0
...
...
@@ -177,11 +177,12 @@ locate_tag_search(const struct song *song, enum tag_type type, const char *str)
}
bool
locate_song_search
(
const
struct
song
*
song
,
int
num_items
,
const
struct
locate_item
*
items
)
locate_song_search
(
const
struct
song
*
song
,
const
struct
locate_item
_list
*
criteria
)
{
for
(
int
i
=
0
;
i
<
num_items
;
i
++
)
if
(
!
locate_tag_search
(
song
,
items
[
i
].
tag
,
items
[
i
].
needle
))
for
(
unsigned
i
=
0
;
i
<
criteria
->
length
;
i
++
)
if
(
!
locate_tag_search
(
song
,
criteria
->
items
[
i
].
tag
,
criteria
->
items
[
i
].
needle
))
return
false
;
return
true
;
...
...
@@ -234,11 +235,12 @@ locate_tag_match(const struct song *song, enum tag_type type, const char *str)
}
bool
locate_song_match
(
const
struct
song
*
song
,
int
num_items
,
const
struct
locate_item
*
items
)
locate_song_match
(
const
struct
song
*
song
,
const
struct
locate_item
_list
*
criteria
)
{
for
(
int
i
=
0
;
i
<
num_items
;
i
++
)
if
(
!
locate_tag_match
(
song
,
items
[
i
].
tag
,
items
[
i
].
needle
))
for
(
unsigned
i
=
0
;
i
<
criteria
->
length
;
i
++
)
if
(
!
locate_tag_match
(
song
,
criteria
->
items
[
i
].
tag
,
criteria
->
items
[
i
].
needle
))
return
false
;
return
true
;
...
...
src/locate.h
View file @
6a2118d0
...
...
@@ -70,11 +70,11 @@ void
locate_item_free
(
struct
locate_item
*
item
);
bool
locate_song_search
(
const
struct
song
*
song
,
int
numItems
,
const
struct
locate_item
*
items
);
locate_song_search
(
const
struct
song
*
song
,
const
struct
locate_item
_list
*
criteria
);
bool
locate_song_match
(
const
struct
song
*
song
,
int
numItems
,
const
struct
locate_item
*
items
);
locate_song_match
(
const
struct
song
*
song
,
const
struct
locate_item_list
*
criteria
);
#endif
src/queue_print.c
View file @
6a2118d0
...
...
@@ -81,19 +81,20 @@ queue_print_changes_position(struct client *client, const struct queue *queue,
void
queue_search
(
struct
client
*
client
,
const
struct
queue
*
queue
,
unsigned
num_items
,
const
struct
locate_item
*
items
)
const
struct
locate_item_list
*
criteria
)
{
unsigned
i
;
struct
locate_item_list
*
new_list
=
locate_item_list_new
(
num_items
);
struct
locate_item_list
*
new_list
=
locate_item_list_new
(
criteria
->
length
);
for
(
i
=
0
;
i
<
num_items
;
i
++
)
for
(
i
=
0
;
i
<
criteria
->
length
;
i
++
)
new_list
->
items
[
i
].
needle
=
g_utf8_casefold
(
items
[
i
].
needle
,
-
1
);
g_utf8_casefold
(
criteria
->
items
[
i
].
needle
,
-
1
);
for
(
i
=
0
;
i
<
queue_length
(
queue
);
i
++
)
{
const
struct
song
*
song
=
queue_get
(
queue
,
i
);
if
(
locate_song_search
(
song
,
n
um_items
,
new_list
->
items
))
if
(
locate_song_search
(
song
,
n
ew_list
))
queue_print_song_info
(
client
,
queue
,
i
);
}
...
...
@@ -102,12 +103,12 @@ queue_search(struct client *client, const struct queue *queue,
void
queue_find
(
struct
client
*
client
,
const
struct
queue
*
queue
,
unsigned
num_items
,
const
struct
locate_item
*
items
)
const
struct
locate_item_list
*
criteria
)
{
for
(
unsigned
i
=
0
;
i
<
queue_length
(
queue
);
i
++
)
{
const
struct
song
*
song
=
queue_get
(
queue
,
i
);
if
(
locate_song_match
(
song
,
num_items
,
items
))
if
(
locate_song_match
(
song
,
criteria
))
queue_print_song_info
(
client
,
queue
,
i
);
}
}
src/queue_print.h
View file @
6a2118d0
...
...
@@ -28,7 +28,7 @@
struct
client
;
struct
queue
;
struct
locate_item
;
struct
locate_item
_list
;
void
queue_print_song_info
(
struct
client
*
client
,
const
struct
queue
*
queue
,
...
...
@@ -60,10 +60,10 @@ queue_print_changes_position(struct client *client, const struct queue *queue,
void
queue_search
(
struct
client
*
client
,
const
struct
queue
*
queue
,
unsigned
num_items
,
const
struct
locate_item
*
items
);
const
struct
locate_item_list
*
criteria
);
void
queue_find
(
struct
client
*
client
,
const
struct
queue
*
queue
,
unsigned
num_items
,
const
struct
locate_item
*
items
);
const
struct
locate_item_list
*
criteria
);
#endif
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