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
75c2029b
Commit
75c2029b
authored
Feb 27, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag: no CamelCase
Renamed numOfItems to num_items.
parent
5b07cbf0
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
60 additions
and
65 deletions
+60
-65
command.c
src/command.c
+1
-1
dbUtils.c
src/dbUtils.c
+3
-3
_flac_common.c
src/decoder/_flac_common.c
+1
-1
vorbis_plugin.c
src/decoder/vorbis_plugin.c
+1
-1
vorbis_encoder.c
src/encoder/vorbis_encoder.c
+1
-1
locate.c
src/locate.c
+3
-4
shout_plugin.c
src/output/shout_plugin.c
+1
-2
song_save.c
src/song_save.c
+2
-2
stats.c
src/stats.c
+1
-1
tag.c
src/tag.c
+38
-37
tag.h
src/tag.h
+3
-3
tag_print.c
src/tag_print.c
+3
-5
tag_save.c
src/tag_save.c
+2
-4
No files found.
src/command.c
View file @
75c2029b
...
...
@@ -1141,7 +1141,7 @@ handle_list(struct client *client, int argc, char *argv[])
if
(
tagType
!=
TAG_ITEM_ALBUM
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"should be
\"
%s
\"
for 3 arguments"
,
mpdTagItemKey
s
[
TAG_ITEM_ALBUM
]);
tag_item_name
s
[
TAG_ITEM_ALBUM
]);
return
COMMAND_RETURN_ERROR
;
}
...
...
src/dbUtils.c
View file @
75c2029b
...
...
@@ -233,7 +233,6 @@ static void
visitTag
(
struct
client
*
client
,
struct
strset
*
set
,
struct
song
*
song
,
enum
tag_type
tagType
)
{
int
i
;
struct
tag
*
tag
=
song
->
tag
;
if
(
tagType
==
LOCATE_TAG_FILE_TYPE
)
{
...
...
@@ -244,12 +243,13 @@ visitTag(struct client *client, struct strset *set,
if
(
!
tag
)
return
;
for
(
i
=
0
;
i
<
tag
->
numOfI
tems
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num_i
tems
;
i
++
)
{
if
(
tag
->
items
[
i
]
->
type
==
tagType
)
{
strset_add
(
set
,
tag
->
items
[
i
]
->
value
);
return
;
}
}
strset_add
(
set
,
""
);
}
...
...
@@ -294,7 +294,7 @@ int listAllUniqueTags(struct client *client, int type,
while
((
value
=
strset_next
(
data
.
set
))
!=
NULL
)
client_printf
(
client
,
"%s: %s
\n
"
,
mpdTagItemKey
s
[
type
],
tag_item_name
s
[
type
],
value
);
strset_free
(
data
.
set
);
...
...
src/decoder/_flac_common.c
View file @
75c2029b
...
...
@@ -158,7 +158,7 @@ flac_parse_comment(struct tag *tag,
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
if
(
flac_copy_comment
(
tag
,
entry
,
mpdTagItemKey
s
[
i
],
i
))
tag_item_name
s
[
i
],
i
))
return
;
}
...
...
src/decoder/vorbis_plugin.c
View file @
75c2029b
...
...
@@ -183,7 +183,7 @@ vorbis_parse_comment(struct tag *tag, const char *comment)
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
if
(
vorbis_copy_comment
(
tag
,
comment
,
mpdTagItemKey
s
[
i
],
i
))
tag_item_name
s
[
i
],
i
))
return
;
}
...
...
src/encoder/vorbis_encoder.c
View file @
75c2029b
...
...
@@ -274,7 +274,7 @@ static void
copy_tag_to_vorbis_comment
(
struct
vorbis_encoder
*
encoder
,
const
struct
tag
*
tag
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num
OfI
tems
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num
_i
tems
;
i
++
)
{
switch
(
tag
->
items
[
i
]
->
type
)
{
case
TAG_ITEM_ARTIST
:
add_tag
(
encoder
,
"ARTIST"
,
tag
->
items
[
i
]
->
value
);
...
...
src/locate.c
View file @
75c2029b
...
...
@@ -42,7 +42,7 @@ locate_parse_type(const char *str)
return
LOCATE_TAG_ANY_TYPE
;
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
if
(
0
==
strcasecmp
(
str
,
mpdTagItemKey
s
[
i
]))
if
(
0
==
strcasecmp
(
str
,
tag_item_name
s
[
i
]))
return
i
;
return
-
1
;
...
...
@@ -165,7 +165,7 @@ locate_tag_search(const struct song *song, enum tag_type type, const char *str)
memset
(
visited_types
,
0
,
sizeof
(
visited_types
));
for
(
i
=
0
;
i
<
song
->
tag
->
num
OfI
tems
&&
!
ret
;
i
++
)
{
for
(
i
=
0
;
i
<
song
->
tag
->
num
_i
tems
&&
!
ret
;
i
++
)
{
visited_types
[
song
->
tag
->
items
[
i
]
->
type
]
=
true
;
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
...
...
@@ -205,7 +205,6 @@ locate_song_search(const struct song *song,
static
bool
locate_tag_match
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
{
int
i
;
bool
visited_types
[
TAG_NUM_OF_ITEM_TYPES
];
if
(
type
==
LOCATE_TAG_FILE_TYPE
||
type
==
LOCATE_TAG_ANY_TYPE
)
{
...
...
@@ -225,7 +224,7 @@ locate_tag_match(const struct song *song, enum tag_type type, const char *str)
memset
(
visited_types
,
0
,
sizeof
(
visited_types
));
for
(
i
=
0
;
i
<
song
->
tag
->
numOfI
tems
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
song
->
tag
->
num_i
tems
;
i
++
)
{
visited_types
[
song
->
tag
->
items
[
i
]
->
type
]
=
true
;
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
...
...
src/output/shout_plugin.c
View file @
75c2029b
...
...
@@ -457,12 +457,11 @@ shout_tag_to_metadata(const struct tag *tag, char *dest, size_t size)
{
char
artist
[
size
];
char
title
[
size
];
int
i
;
artist
[
0
]
=
0
;
title
[
0
]
=
0
;
for
(
i
=
0
;
i
<
tag
->
numOfI
tems
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num_i
tems
;
i
++
)
{
switch
(
tag
->
items
[
i
]
->
type
)
{
case
TAG_ITEM_ARTIST
:
strncpy
(
artist
,
tag
->
items
[
i
]
->
value
,
size
);
...
...
src/song_save.c
View file @
75c2029b
...
...
@@ -92,9 +92,9 @@ matchesAnMpdTagItemKey(char *buffer, enum tag_type *itemType)
int
i
;
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
{
size_t
len
=
strlen
(
mpdTagItemKey
s
[
i
]);
size_t
len
=
strlen
(
tag_item_name
s
[
i
]);
if
(
0
==
strncmp
(
mpdTagItemKey
s
[
i
],
buffer
,
len
)
&&
if
(
0
==
strncmp
(
tag_item_name
s
[
i
],
buffer
,
len
)
&&
buffer
[
len
]
==
':'
)
{
*
itemType
=
i
;
return
g_strchug
(
buffer
+
len
+
1
);
...
...
src/stats.c
View file @
75c2029b
...
...
@@ -48,7 +48,7 @@ visit_tag(struct visit_data *data, const struct tag *tag)
if
(
tag
->
time
>
0
)
stats
.
song_duration
+=
tag
->
time
;
for
(
unsigned
i
=
0
;
i
<
tag
->
num
OfI
tems
;
++
i
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num
_i
tems
;
++
i
)
{
const
struct
tag_item
*
item
=
tag
->
items
[
i
];
switch
(
item
->
type
)
{
...
...
src/tag.c
View file @
75c2029b
...
...
@@ -41,7 +41,7 @@ static struct {
struct
tag_item
*
items
[
BULK_MAX
];
}
bulk
;
const
char
*
mpdTagItemKey
s
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
const
char
*
tag_item_name
s
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
"Artist"
,
"Album"
,
"AlbumArtist"
,
...
...
@@ -66,7 +66,7 @@ int8_t ignoreTagItems[TAG_NUM_OF_ITEM_TYPES];
static
size_t
items_size
(
const
struct
tag
*
tag
)
{
return
(
tag
->
numOfItems
*
sizeof
(
struct
tag_item
*
)
);
return
tag
->
num_items
*
sizeof
(
struct
tag_item
*
);
}
void
tag_lib_init
(
void
)
...
...
@@ -99,7 +99,7 @@ void tag_lib_init(void)
quit
=
1
;
*
s
=
'\0'
;
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
{
if
(
strcasecmp
(
c
,
mpdTagItemKey
s
[
i
])
==
0
)
{
if
(
strcasecmp
(
c
,
tag_item_name
s
[
i
])
==
0
)
{
ignoreTagItems
[
i
]
=
0
;
break
;
}
...
...
@@ -242,25 +242,25 @@ struct tag *tag_new(void)
struct
tag
*
ret
=
g_new
(
struct
tag
,
1
);
ret
->
items
=
NULL
;
ret
->
time
=
-
1
;
ret
->
num
OfI
tems
=
0
;
ret
->
num
_i
tems
=
0
;
return
ret
;
}
static
void
deleteI
tem
(
struct
tag
*
tag
,
int
idx
)
static
void
tag_delete_i
tem
(
struct
tag
*
tag
,
int
idx
)
{
assert
(
idx
<
tag
->
num
OfI
tems
);
tag
->
num
OfI
tems
--
;
assert
(
idx
<
tag
->
num
_i
tems
);
tag
->
num
_i
tems
--
;
g_mutex_lock
(
tag_pool_lock
);
tag_pool_put_item
(
tag
->
items
[
idx
]);
g_mutex_unlock
(
tag_pool_lock
);
if
(
tag
->
num
OfI
tems
-
idx
>
0
)
{
if
(
tag
->
num
_i
tems
-
idx
>
0
)
{
memmove
(
tag
->
items
+
idx
,
tag
->
items
+
idx
+
1
,
tag
->
num
OfI
tems
-
idx
);
tag
->
num
_i
tems
-
idx
);
}
if
(
tag
->
num
OfI
tems
>
0
)
{
if
(
tag
->
num
_i
tems
>
0
)
{
tag
->
items
=
g_realloc
(
tag
->
items
,
items_size
(
tag
));
}
else
{
g_free
(
tag
->
items
);
...
...
@@ -272,9 +272,9 @@ void tag_clear_items_by_type(struct tag *tag, enum tag_type type)
{
int
i
;
for
(
i
=
0
;
i
<
tag
->
num
OfI
tems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag
->
num
_i
tems
;
i
++
)
{
if
(
tag
->
items
[
i
]
->
type
==
type
)
{
deleteI
tem
(
tag
,
i
);
tag_delete_i
tem
(
tag
,
i
);
/* decrement since when just deleted this node */
i
--
;
}
...
...
@@ -286,7 +286,7 @@ void tag_free(struct tag *tag)
int
i
;
g_mutex_lock
(
tag_pool_lock
);
for
(
i
=
tag
->
num
OfI
tems
;
--
i
>=
0
;
)
for
(
i
=
tag
->
num
_i
tems
;
--
i
>=
0
;
)
tag_pool_put_item
(
tag
->
items
[
i
]);
g_mutex_unlock
(
tag_pool_lock
);
...
...
@@ -311,11 +311,11 @@ struct tag *tag_dup(const struct tag *tag)
ret
=
tag_new
();
ret
->
time
=
tag
->
time
;
ret
->
num
OfItems
=
tag
->
numOfI
tems
;
ret
->
items
=
ret
->
num
OfI
tems
>
0
?
g_malloc
(
items_size
(
tag
))
:
NULL
;
ret
->
num
_items
=
tag
->
num_i
tems
;
ret
->
items
=
ret
->
num
_i
tems
>
0
?
g_malloc
(
items_size
(
tag
))
:
NULL
;
g_mutex_lock
(
tag_pool_lock
);
for
(
i
=
0
;
i
<
tag
->
num
OfI
tems
;
i
++
)
for
(
i
=
0
;
i
<
tag
->
num
_i
tems
;
i
++
)
ret
->
items
[
i
]
=
tag_pool_dup_item
(
tag
->
items
[
i
]);
g_mutex_unlock
(
tag_pool_lock
);
...
...
@@ -335,33 +335,33 @@ tag_merge(const struct tag *base, const struct tag *add)
ret
=
tag_new
();
ret
->
time
=
add
->
time
>
0
?
add
->
time
:
base
->
time
;
ret
->
num
OfItems
=
base
->
numOfItems
+
add
->
numOfI
tems
;
ret
->
items
=
ret
->
num
OfI
tems
>
0
?
g_malloc
(
items_size
(
ret
))
:
NULL
;
ret
->
num
_items
=
base
->
num_items
+
add
->
num_i
tems
;
ret
->
items
=
ret
->
num
_i
tems
>
0
?
g_malloc
(
items_size
(
ret
))
:
NULL
;
g_mutex_lock
(
tag_pool_lock
);
/* copy all items from "add" */
for
(
unsigned
i
=
0
;
i
<
add
->
num
OfI
tems
;
++
i
)
for
(
unsigned
i
=
0
;
i
<
add
->
num
_i
tems
;
++
i
)
ret
->
items
[
i
]
=
tag_pool_dup_item
(
add
->
items
[
i
]);
n
=
add
->
num
OfI
tems
;
n
=
add
->
num
_i
tems
;
/* copy additional items from "base" */
for
(
unsigned
i
=
0
;
i
<
base
->
num
OfI
tems
;
++
i
)
for
(
unsigned
i
=
0
;
i
<
base
->
num
_i
tems
;
++
i
)
if
(
!
tag_has_type
(
add
,
base
->
items
[
i
]
->
type
))
ret
->
items
[
n
++
]
=
tag_pool_dup_item
(
base
->
items
[
i
]);
g_mutex_unlock
(
tag_pool_lock
);
assert
(
n
<=
ret
->
num
OfI
tems
);
assert
(
n
<=
ret
->
num
_i
tems
);
if
(
n
<
ret
->
num
OfI
tems
)
{
if
(
n
<
ret
->
num
_i
tems
)
{
/* some tags were not copied - shrink ret->items */
assert
(
n
>
0
);
ret
->
num
OfI
tems
=
n
;
ret
->
num
_i
tems
=
n
;
ret
->
items
=
g_realloc
(
ret
->
items
,
items_size
(
ret
));
}
...
...
@@ -374,7 +374,7 @@ tag_get_value(const struct tag *tag, enum tag_type type)
assert
(
tag
!=
NULL
);
assert
(
type
<
TAG_NUM_OF_ITEM_TYPES
);
for
(
unsigned
i
=
0
;
i
<
tag
->
num
OfI
tems
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
tag
->
num
_i
tems
;
i
++
)
if
(
tag
->
items
[
i
]
->
type
==
type
)
return
tag
->
items
[
i
]
->
value
;
...
...
@@ -398,10 +398,10 @@ bool tag_equal(const struct tag *tag1, const struct tag *tag2)
if
(
tag1
->
time
!=
tag2
->
time
)
return
false
;
if
(
tag1
->
num
OfItems
!=
tag2
->
numOfI
tems
)
if
(
tag1
->
num
_items
!=
tag2
->
num_i
tems
)
return
false
;
for
(
i
=
0
;
i
<
tag1
->
num
OfI
tems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag1
->
num
_i
tems
;
i
++
)
{
if
(
tag1
->
items
[
i
]
->
type
!=
tag2
->
items
[
i
]
->
type
)
return
false
;
if
(
strcmp
(
tag1
->
items
[
i
]
->
value
,
tag2
->
items
[
i
]
->
value
))
{
...
...
@@ -437,7 +437,7 @@ void tag_begin_add(struct tag *tag)
assert
(
!
bulk
.
busy
);
assert
(
tag
!=
NULL
);
assert
(
tag
->
items
==
NULL
);
assert
(
tag
->
num
OfI
tems
==
0
);
assert
(
tag
->
num
_i
tems
==
0
);
#ifndef NDEBUG
bulk
.
busy
=
true
;
...
...
@@ -448,9 +448,9 @@ void tag_begin_add(struct tag *tag)
void
tag_end_add
(
struct
tag
*
tag
)
{
if
(
tag
->
items
==
bulk
.
items
)
{
assert
(
tag
->
num
OfI
tems
<=
BULK_MAX
);
assert
(
tag
->
num
_i
tems
<=
BULK_MAX
);
if
(
tag
->
num
OfI
tems
>
0
)
{
if
(
tag
->
num
_i
tems
>
0
)
{
/* copy the tag items from the bulk list over
to a new list (which fits exactly) */
tag
->
items
=
g_malloc
(
items_size
(
tag
));
...
...
@@ -522,10 +522,11 @@ fix_tag_value(const char *p, size_t length)
return
cleared
;
}
static
void
appendToTagItems
(
struct
tag
*
tag
,
enum
tag_type
type
,
const
char
*
value
,
size_t
len
)
static
void
tag_add_item_internal
(
struct
tag
*
tag
,
enum
tag_type
type
,
const
char
*
value
,
size_t
len
)
{
unsigned
int
i
=
tag
->
num
OfI
tems
;
unsigned
int
i
=
tag
->
num
_i
tems
;
char
*
p
;
p
=
fix_tag_value
(
value
,
len
);
...
...
@@ -534,12 +535,12 @@ static void appendToTagItems(struct tag *tag, enum tag_type type,
len
=
strlen
(
value
);
}
tag
->
num
OfI
tems
++
;
tag
->
num
_i
tems
++
;
if
(
tag
->
items
!=
bulk
.
items
)
/* bulk mode disabled */
tag
->
items
=
g_realloc
(
tag
->
items
,
items_size
(
tag
));
else
if
(
tag
->
num
OfI
tems
>=
BULK_MAX
)
{
else
if
(
tag
->
num
_i
tems
>=
BULK_MAX
)
{
/* bulk list already full - switch back to non-bulk */
assert
(
bulk
.
busy
);
...
...
@@ -566,8 +567,8 @@ void tag_add_item_n(struct tag *tag, enum tag_type itemType,
return
;
/* we can't hold more than 255 items */
if
(
tag
->
num
OfI
tems
==
255
)
if
(
tag
->
num
_i
tems
==
255
)
return
;
appendToTagItems
(
tag
,
itemType
,
value
,
len
);
tag_add_item_internal
(
tag
,
itemType
,
value
,
len
);
}
src/tag.h
View file @
75c2029b
...
...
@@ -48,7 +48,7 @@ enum tag_type {
TAG_NUM_OF_ITEM_TYPES
};
extern
const
char
*
mpdTagItemKey
s
[];
extern
const
char
*
tag_item_name
s
[];
struct
tag_item
{
enum
tag_type
type
;
...
...
@@ -58,7 +58,7 @@ struct tag_item {
struct
tag
{
int
time
;
struct
tag_item
**
items
;
uint8_t
num
OfI
tems
;
uint8_t
num
_i
tems
;
};
struct
tag
*
tag_ape_load
(
const
char
*
file
);
...
...
@@ -112,7 +112,7 @@ tag_merge(const struct tag *base, const struct tag *add);
static
inline
bool
tag_is_empty
(
const
struct
tag
*
tag
)
{
return
tag
->
num
OfI
tems
==
0
;
return
tag
->
num
_i
tems
==
0
;
}
/**
...
...
src/tag_print.c
View file @
75c2029b
...
...
@@ -29,20 +29,18 @@ void tag_print_types(struct client *client)
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
{
if
(
ignoreTagItems
[
i
]
==
0
)
client_printf
(
client
,
"tagtype: %s
\n
"
,
mpdTagItemKey
s
[
i
]);
tag_item_name
s
[
i
]);
}
}
void
tag_print
(
struct
client
*
client
,
const
struct
tag
*
tag
)
{
int
i
;
if
(
tag
->
time
>=
0
)
client_printf
(
client
,
SONG_TIME
"%i
\n
"
,
tag
->
time
);
for
(
i
=
0
;
i
<
tag
->
numOfI
tems
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num_i
tems
;
i
++
)
{
client_printf
(
client
,
"%s: %s
\n
"
,
mpdTagItemKey
s
[
tag
->
items
[
i
]
->
type
],
tag_item_name
s
[
tag
->
items
[
i
]
->
type
],
tag
->
items
[
i
]
->
value
);
}
}
src/tag_save.c
View file @
75c2029b
...
...
@@ -23,13 +23,11 @@
void
tag_save
(
FILE
*
file
,
const
struct
tag
*
tag
)
{
int
i
;
if
(
tag
->
time
>=
0
)
fprintf
(
file
,
SONG_TIME
"%i
\n
"
,
tag
->
time
);
for
(
i
=
0
;
i
<
tag
->
numOfI
tems
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
tag
->
num_i
tems
;
i
++
)
fprintf
(
file
,
"%s: %s
\n
"
,
mpdTagItemKey
s
[
tag
->
items
[
i
]
->
type
],
tag_item_name
s
[
tag
->
items
[
i
]
->
type
],
tag
->
items
[
i
]
->
value
);
}
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