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
3582977e
Commit
3582977e
authored
Jan 24, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
locate: no CamelCase
Renamed functions and variables.
parent
daa5f592
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
89 deletions
+76
-89
command.c
src/command.c
+14
-14
dbUtils.c
src/dbUtils.c
+7
-7
locate.c
src/locate.c
+39
-54
locate.h
src/locate.h
+13
-11
queue_print.c
src/queue_print.c
+3
-3
No files found.
src/command.c
View file @
3582977e
...
...
@@ -834,7 +834,7 @@ handle_find(struct client *client, int argc, char *argv[])
{
int
ret
;
struct
locate_item
*
items
;
int
numItems
=
newLocateTagItemArrayFromArgArray
(
argv
+
1
,
int
numItems
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
&
items
);
...
...
@@ -848,7 +848,7 @@ handle_find(struct client *client, int argc, char *argv[])
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
freeLocateTagItemArray
(
numItems
,
items
);
locate_item_list_free
(
numItems
,
items
);
return
ret
;
}
...
...
@@ -858,7 +858,7 @@ handle_search(struct client *client, int argc, char *argv[])
{
int
ret
;
struct
locate_item
*
items
;
int
numItems
=
newLocateTagItemArrayFromArgArray
(
argv
+
1
,
int
numItems
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
&
items
);
...
...
@@ -872,7 +872,7 @@ handle_search(struct client *client, int argc, char *argv[])
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
freeLocateTagItemArray
(
numItems
,
items
);
locate_item_list_free
(
numItems
,
items
);
return
ret
;
}
...
...
@@ -882,7 +882,7 @@ handle_count(struct client *client, int argc, char *argv[])
{
int
ret
;
struct
locate_item
*
items
;
int
numItems
=
newLocateTagItemArrayFromArgArray
(
argv
+
1
,
int
numItems
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
&
items
);
...
...
@@ -896,7 +896,7 @@ handle_count(struct client *client, int argc, char *argv[])
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
freeLocateTagItemArray
(
numItems
,
items
);
locate_item_list_free
(
numItems
,
items
);
return
ret
;
}
...
...
@@ -905,7 +905,7 @@ static enum command_return
handle_playlistfind
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
struct
locate_item
*
items
;
int
numItems
=
newLocateTagItemArrayFromArgArray
(
argv
+
1
,
int
numItems
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
&
items
);
...
...
@@ -916,7 +916,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
queue_find
(
client
,
playlist_get_queue
(),
numItems
,
items
);
freeLocateTagItemArray
(
numItems
,
items
);
locate_item_list_free
(
numItems
,
items
);
return
COMMAND_RETURN_OK
;
}
...
...
@@ -925,7 +925,7 @@ static enum command_return
handle_playlistsearch
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
struct
locate_item
*
items
;
int
numItems
=
newLocateTagItemArrayFromArgArray
(
argv
+
1
,
int
numItems
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
&
items
);
...
...
@@ -936,7 +936,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
queue_search
(
client
,
playlist_get_queue
(),
numItems
,
items
);
freeLocateTagItemArray
(
numItems
,
items
);
locate_item_list_free
(
numItems
,
items
);
return
COMMAND_RETURN_OK
;
}
...
...
@@ -1113,7 +1113,7 @@ handle_list(struct client *client, int argc, char *argv[])
{
int
numConditionals
;
struct
locate_item
*
conditionals
=
NULL
;
int
tagType
=
getLocateTagItemT
ype
(
argv
[
1
]);
int
tagType
=
locate_parse_t
ype
(
argv
[
1
]);
int
ret
;
if
(
tagType
<
0
)
{
...
...
@@ -1135,12 +1135,12 @@ handle_list(struct client *client, int argc, char *argv[])
mpdTagItemKeys
[
TAG_ITEM_ALBUM
]);
return
COMMAND_RETURN_ERROR
;
}
conditionals
=
newLocateTagItem
(
mpdTagItemKeys
[
TAG_ITEM_ARTIST
],
conditionals
=
locate_item_new
(
mpdTagItemKeys
[
TAG_ITEM_ARTIST
],
argv
[
2
]);
numConditionals
=
1
;
}
else
{
numConditionals
=
newLocateTagItemArrayFromArgArray
(
argv
+
2
,
locate_item_list_parse
(
argv
+
2
,
argc
-
2
,
&
conditionals
);
if
(
numConditionals
<
0
)
{
...
...
@@ -1153,7 +1153,7 @@ handle_list(struct client *client, int argc, char *argv[])
ret
=
listAllUniqueTags
(
client
,
tagType
,
numConditionals
,
conditionals
);
if
(
conditionals
)
freeLocateTagItemArray
(
numConditionals
,
conditionals
);
locate_item_list_free
(
numConditionals
,
conditionals
);
if
(
ret
==
-
1
)
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
...
...
src/dbUtils.c
View file @
3582977e
...
...
@@ -80,7 +80,7 @@ searchInDirectory(struct song *song, void *_data)
struct
search_data
*
data
=
_data
;
LocateTagItemArray
*
array
=
&
data
->
array
;
if
(
strstrSearchTags
(
song
,
array
->
numItems
,
array
->
items
))
if
(
locate_song_search
(
song
,
array
->
numItems
,
array
->
items
))
return
song_print_info
(
data
->
client
,
song
);
return
0
;
...
...
@@ -105,7 +105,7 @@ searchForSongsIn(struct client *client, const char *name,
ret
=
db_walk
(
name
,
searchInDirectory
,
NULL
,
&
data
);
freeLocateTagItemArray
(
numItems
,
new_items
);
locate_item_list_free
(
numItems
,
new_items
);
return
ret
;
}
...
...
@@ -116,7 +116,7 @@ findInDirectory(struct song *song, void *_data)
struct
search_data
*
data
=
_data
;
LocateTagItemArray
*
array
=
&
data
->
array
;
if
(
tagItemsFoundAndMatches
(
song
,
array
->
numItems
,
array
->
items
))
if
(
locate_song_match
(
song
,
array
->
numItems
,
array
->
items
))
return
song_print_info
(
data
->
client
,
song
);
return
0
;
...
...
@@ -146,8 +146,8 @@ searchStatsInDirectory(struct song *song, void *data)
{
SearchStats
*
stats
=
data
;
if
(
tagItemsFoundAndMatches
(
song
,
stats
->
locateArray
.
numItems
,
stats
->
locateArray
.
items
))
{
if
(
locate_song_match
(
song
,
stats
->
locateArray
.
numItems
,
stats
->
locateArray
.
items
))
{
stats
->
numberOfSongs
++
;
if
(
song
->
tag
->
time
>
0
)
stats
->
playTime
+=
song
->
tag
->
time
;
...
...
@@ -283,8 +283,8 @@ listUniqueTagsInDirectory(struct song *song, void *_data)
struct
list_tags_data
*
data
=
_data
;
ListCommandItem
*
item
=
data
->
item
;
if
(
tagItemsFoundAndMatches
(
song
,
item
->
numConditionals
,
item
->
conditionals
))
{
if
(
locate_song_match
(
song
,
item
->
numConditionals
,
item
->
conditionals
))
{
visitTag
(
data
->
client
,
data
->
set
,
song
,
item
->
tagType
);
}
...
...
src/locate.c
View file @
3582977e
...
...
@@ -29,36 +29,32 @@
#define LOCATE_TAG_FILE_KEY_OLD "filename"
#define LOCATE_TAG_ANY_KEY "any"
int
getLocateTagItemType
(
const
char
*
str
)
int
locate_parse_type
(
const
char
*
str
)
{
int
i
;
if
(
0
==
strcasecmp
(
str
,
LOCATE_TAG_FILE_KEY
)
||
0
==
strcasecmp
(
str
,
LOCATE_TAG_FILE_KEY_OLD
))
{
0
==
strcasecmp
(
str
,
LOCATE_TAG_FILE_KEY_OLD
))
return
LOCATE_TAG_FILE_TYPE
;
}
if
(
0
==
strcasecmp
(
str
,
LOCATE_TAG_ANY_KEY
))
{
if
(
0
==
strcasecmp
(
str
,
LOCATE_TAG_ANY_KEY
))
return
LOCATE_TAG_ANY_TYPE
;
}
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
{
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
if
(
0
==
strcasecmp
(
str
,
mpdTagItemKeys
[
i
]))
return
i
;
}
return
-
1
;
}
static
int
initLocateTagItem
(
struct
locate_item
*
item
,
const
char
*
typeStr
,
const
char
*
needle
)
static
int
locate_item_init
(
struct
locate_item
*
item
,
const
char
*
type_string
,
const
char
*
needle
)
{
item
->
tag
Type
=
getLocateTagItemType
(
typeStr
);
item
->
tag
=
locate_parse_type
(
type_string
);
if
(
item
->
tag
Type
<
0
)
if
(
item
->
tag
<
0
)
return
-
1
;
item
->
needle
=
g_strdup
(
needle
);
...
...
@@ -67,11 +63,11 @@ static int initLocateTagItem(struct locate_item *item,
}
struct
locate_item
*
newLocateTagItem
(
const
char
*
typeStr
,
const
char
*
needle
)
locate_item_new
(
const
char
*
type_string
,
const
char
*
needle
)
{
struct
locate_item
*
ret
=
g_new
(
struct
locate_item
,
1
);
if
(
initLocateTagItem
(
ret
,
typeStr
,
needle
)
<
0
)
{
if
(
locate_item_init
(
ret
,
type_string
,
needle
)
<
0
)
{
free
(
ret
);
ret
=
NULL
;
}
...
...
@@ -79,7 +75,8 @@ newLocateTagItem(const char *typeStr, const char *needle)
return
ret
;
}
void
freeLocateTagItemArray
(
int
count
,
struct
locate_item
*
array
)
void
locate_item_list_free
(
int
count
,
struct
locate_item
*
array
)
{
int
i
;
...
...
@@ -90,27 +87,25 @@ void freeLocateTagItemArray(int count, struct locate_item *array)
}
int
newLocateTagItemArrayFromArgArray
(
char
*
argArray
[],
int
numArgs
,
struct
locate_item
**
arrayRet
)
locate_item_list_parse
(
char
*
argv
[],
int
argc
,
struct
locate_item
**
arrayRet
)
{
int
i
,
j
;
struct
locate_item
*
item
;
if
(
numArgs
==
0
)
if
(
argc
==
0
)
return
0
;
if
(
numArgs
%
2
!=
0
)
if
(
argc
%
2
!=
0
)
return
-
1
;
*
arrayRet
=
g_new
(
struct
locate_item
,
numArgs
/
2
);
*
arrayRet
=
g_new
(
struct
locate_item
,
argc
/
2
);
for
(
i
=
0
,
item
=
*
arrayRet
;
i
<
numArgs
/
2
;
i
++
,
item
++
)
{
if
(
initLocateTagItem
(
item
,
argArray
[
i
*
2
],
argArray
[
i
*
2
+
1
])
<
0
)
for
(
i
=
0
,
item
=
*
arrayRet
;
i
<
argc
/
2
;
i
++
,
item
++
)
{
if
(
locate_item_init
(
item
,
argv
[
i
*
2
],
argv
[
i
*
2
+
1
])
<
0
)
goto
fail
;
}
return
numArgs
/
2
;
return
argc
/
2
;
fail:
for
(
j
=
0
;
j
<
i
;
j
++
)
{
...
...
@@ -122,19 +117,20 @@ fail:
return
-
1
;
}
void
freeLocateTagItem
(
struct
locate_item
*
item
)
void
locate_item_free
(
struct
locate_item
*
item
)
{
free
(
item
->
needle
);
free
(
item
);
}
static
int
strstrSearchTag
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
locate_tag_search
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
{
int
i
;
char
*
duplicate
;
int
ret
=
0
;
int8_t
visited
T
ypes
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
0
};
int8_t
visited
_t
ypes
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
0
};
if
(
type
==
LOCATE_TAG_FILE_TYPE
||
type
==
LOCATE_TAG_ANY_TYPE
)
{
char
*
uri
,
*
p
;
...
...
@@ -154,7 +150,7 @@ strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
return
0
;
for
(
i
=
0
;
i
<
song
->
tag
->
numOfItems
&&
!
ret
;
i
++
)
{
visited
T
ypes
[
song
->
tag
->
items
[
i
]
->
type
]
=
1
;
visited
_t
ypes
[
song
->
tag
->
items
[
i
]
->
type
]
=
1
;
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
continue
;
...
...
@@ -172,34 +168,28 @@ strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
* empty (first char is a \0), then it's a match as well and
* we should return 1.
*/
if
(
!*
str
&&
!
visited
T
ypes
[
type
])
if
(
!*
str
&&
!
visited
_t
ypes
[
type
])
return
1
;
return
ret
;
}
int
strstrSearchTags
(
const
struct
song
*
song
,
int
numI
tems
,
const
struct
locate_item
*
items
)
locate_song_search
(
const
struct
song
*
song
,
int
num_i
tems
,
const
struct
locate_item
*
items
)
{
int
i
;
for
(
i
=
0
;
i
<
numItems
;
i
++
)
{
if
(
!
strstrSearchTag
(
song
,
items
[
i
].
tagType
,
items
[
i
].
needle
))
{
for
(
int
i
=
0
;
i
<
num_items
;
i
++
)
if
(
!
locate_tag_search
(
song
,
items
[
i
].
tag
,
items
[
i
].
needle
))
return
0
;
}
}
return
1
;
}
static
int
tagItemFoundAndMatches
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
locate_tag_match
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
{
int
i
;
int8_t
visited
T
ypes
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
0
};
int8_t
visited
_t
ypes
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
0
};
if
(
type
==
LOCATE_TAG_FILE_TYPE
||
type
==
LOCATE_TAG_ANY_TYPE
)
{
char
*
uri
=
song_get_uri
(
song
);
...
...
@@ -217,7 +207,7 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
return
0
;
for
(
i
=
0
;
i
<
song
->
tag
->
numOfItems
;
i
++
)
{
visited
T
ypes
[
song
->
tag
->
items
[
i
]
->
type
]
=
1
;
visited
_t
ypes
[
song
->
tag
->
items
[
i
]
->
type
]
=
1
;
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
continue
;
...
...
@@ -233,7 +223,7 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
* empty (first char is a \0), then it's a match as well and
* we should return 1.
*/
if
(
!*
str
&&
!
visited
T
ypes
[
type
])
if
(
!*
str
&&
!
visited
_t
ypes
[
type
])
return
1
;
return
0
;
...
...
@@ -241,17 +231,12 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
int
tagItemsFoundAndMatches
(
const
struct
song
*
song
,
int
numI
tems
,
const
struct
locate_item
*
items
)
locate_song_match
(
const
struct
song
*
song
,
int
num_i
tems
,
const
struct
locate_item
*
items
)
{
int
i
;
for
(
i
=
0
;
i
<
numItems
;
i
++
)
{
if
(
!
tagItemFoundAndMatches
(
song
,
items
[
i
].
tagType
,
items
[
i
].
needle
))
{
for
(
int
i
=
0
;
i
<
num_items
;
i
++
)
if
(
!
locate_tag_match
(
song
,
items
[
i
].
tag
,
items
[
i
].
needle
))
return
0
;
}
}
return
1
;
}
src/locate.h
View file @
3582977e
...
...
@@ -28,32 +28,34 @@ struct song;
/* struct used for search, find, list queries */
struct
locate_item
{
int8_t
tag
Type
;
int8_t
tag
;
/* what we are looking for */
char
*
needle
;
};
int
getLocateTagItemType
(
const
char
*
str
);
int
locate_parse_type
(
const
char
*
str
);
/* returns NULL if not a known type */
struct
locate_item
*
newLocateTagItem
(
const
char
*
typeS
tring
,
const
char
*
needle
);
locate_item_new
(
const
char
*
type_s
tring
,
const
char
*
needle
);
/* return number of items or -1 on error */
int
newLocateTagItemArrayFromArgArray
(
char
*
argArray
[],
int
numArgs
,
struct
locate_item
**
arrayRet
);
locate_item_list_parse
(
char
*
argv
[],
int
argc
,
struct
locate_item
**
arrayRet
);
void
freeLocateTagItemArray
(
int
count
,
struct
locate_item
*
array
);
void
locate_item_list_free
(
int
count
,
struct
locate_item
*
array
);
void
freeLocateTagItem
(
struct
locate_item
*
item
);
void
locate_item_free
(
struct
locate_item
*
item
);
int
strstrSearchTags
(
const
struct
song
*
song
,
int
numItems
,
const
struct
locate_item
*
items
);
locate_song_search
(
const
struct
song
*
song
,
int
numItems
,
const
struct
locate_item
*
items
);
int
tagItemsFoundAndMatches
(
const
struct
song
*
song
,
int
numItems
,
const
struct
locate_item
*
items
);
locate_song_match
(
const
struct
song
*
song
,
int
numItems
,
const
struct
locate_item
*
items
);
#endif
src/queue_print.c
View file @
3582977e
...
...
@@ -93,11 +93,11 @@ queue_search(struct client *client, const struct queue *queue,
for
(
i
=
0
;
i
<
queue_length
(
queue
);
i
++
)
{
const
struct
song
*
song
=
queue_get
(
queue
,
i
);
if
(
strstrSearchTags
(
song
,
num_items
,
new_items
))
if
(
locate_song_search
(
song
,
num_items
,
new_items
))
queue_print_song_info
(
client
,
queue
,
i
);
}
freeLocateTagItemArray
(
num_items
,
new_items
);
locate_item_list_free
(
num_items
,
new_items
);
}
void
...
...
@@ -107,7 +107,7 @@ queue_find(struct client *client, const struct queue *queue,
for
(
unsigned
i
=
0
;
i
<
queue_length
(
queue
);
i
++
)
{
const
struct
song
*
song
=
queue_get
(
queue
,
i
);
if
(
tagItemsFoundAndMatches
(
song
,
num_items
,
items
))
if
(
locate_song_match
(
song
,
num_items
,
items
))
queue_print_song_info
(
client
,
queue
,
i
);
}
}
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