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
4a2b315a
Commit
4a2b315a
authored
Feb 28, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag: moved APE code to tag_ape.c
parent
cabbf7ab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
179 additions
and
122 deletions
+179
-122
Makefile.am
Makefile.am
+2
-0
song.c
src/song.c
+1
-0
tag.c
src/tag.c
+0
-120
tag.h
src/tag.h
+0
-2
tag_ape.c
src/tag_ape.c
+145
-0
tag_ape.h
src/tag_ape.h
+31
-0
No files found.
Makefile.am
View file @
4a2b315a
...
...
@@ -120,6 +120,7 @@ mpd_headers = \
src/tag.h
\
src/tag_internal.h
\
src/tag_pool.h
\
src/tag_ape.h
\
src/tag_id3.h
\
src/tag_print.h
\
src/tag_save.h
\
...
...
@@ -209,6 +210,7 @@ src_mpd_SOURCES = \
src/tag_pool.c
\
src/tag_print.c
\
src/tag_save.c
\
src/tag_ape.c
\
src/strset.c
\
src/uri.c
\
src/utils.c
\
...
...
src/song.c
View file @
4a2b315a
...
...
@@ -22,6 +22,7 @@
#include "mapper.h"
#include "decoder_list.h"
#include "decoder_plugin.h"
#include "tag_ape.h"
#include "tag_id3.h"
#include "tag.h"
...
...
src/tag.c
View file @
4a2b315a
...
...
@@ -117,126 +117,6 @@ void tag_lib_init(void)
g_free
(
temp
);
}
struct
tag
*
tag_ape_load
(
const
char
*
file
)
{
struct
tag
*
ret
=
NULL
;
FILE
*
fp
;
int
tagCount
;
char
*
buffer
=
NULL
;
char
*
p
;
size_t
tagLen
;
size_t
size
;
unsigned
long
flags
;
int
i
;
char
*
key
;
struct
{
unsigned
char
id
[
8
];
uint32_t
version
;
uint32_t
length
;
uint32_t
tagCount
;
unsigned
char
flags
[
4
];
unsigned
char
reserved
[
8
];
}
footer
;
const
char
*
apeItems
[
7
]
=
{
"title"
,
"artist"
,
"album"
,
"comment"
,
"genre"
,
"track"
,
"year"
};
int
tagItems
[
7
]
=
{
TAG_ITEM_TITLE
,
TAG_ITEM_ARTIST
,
TAG_ITEM_ALBUM
,
TAG_ITEM_COMMENT
,
TAG_ITEM_GENRE
,
TAG_ITEM_TRACK
,
TAG_ITEM_DATE
,
};
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
NULL
;
/* determine if file has an apeV2 tag */
if
(
fseek
(
fp
,
0
,
SEEK_END
))
goto
fail
;
size
=
(
size_t
)
ftell
(
fp
);
if
(
fseek
(
fp
,
size
-
sizeof
(
footer
),
SEEK_SET
))
goto
fail
;
if
(
fread
(
&
footer
,
1
,
sizeof
(
footer
),
fp
)
!=
sizeof
(
footer
))
goto
fail
;
if
(
memcmp
(
footer
.
id
,
"APETAGEX"
,
sizeof
(
footer
.
id
))
!=
0
)
goto
fail
;
if
(
GUINT32_FROM_LE
(
footer
.
version
)
!=
2000
)
goto
fail
;
/* find beginning of ape tag */
tagLen
=
GUINT32_FROM_LE
(
footer
.
length
);
if
(
tagLen
<
sizeof
(
footer
))
goto
fail
;
if
(
fseek
(
fp
,
size
-
tagLen
,
SEEK_SET
))
goto
fail
;
/* read tag into buffer */
tagLen
-=
sizeof
(
footer
);
if
(
tagLen
<=
0
)
goto
fail
;
buffer
=
g_malloc
(
tagLen
);
if
(
fread
(
buffer
,
1
,
tagLen
,
fp
)
!=
tagLen
)
goto
fail
;
/* read tags */
tagCount
=
GUINT32_FROM_LE
(
footer
.
tagCount
);
p
=
buffer
;
while
(
tagCount
--
&&
tagLen
>
10
)
{
size
=
GUINT32_FROM_LE
(
*
(
const
uint32_t
*
)
p
);
p
+=
4
;
tagLen
-=
4
;
flags
=
GUINT32_FROM_LE
(
*
(
const
uint32_t
*
)
p
);
p
+=
4
;
tagLen
-=
4
;
/* get the key */
key
=
p
;
while
(
tagLen
-
size
>
0
&&
*
p
!=
'\0'
)
{
p
++
;
tagLen
--
;
}
p
++
;
tagLen
--
;
/* get the value */
if
(
tagLen
<
size
)
goto
fail
;
/* we only care about utf-8 text tags */
if
(
!
(
flags
&
(
0x3
<<
1
)))
{
for
(
i
=
0
;
i
<
7
;
i
++
)
{
if
(
strcasecmp
(
key
,
apeItems
[
i
])
==
0
)
{
if
(
!
ret
)
ret
=
tag_new
();
tag_add_item_n
(
ret
,
tagItems
[
i
],
p
,
size
);
}
}
}
p
+=
size
;
tagLen
-=
size
;
}
fail:
if
(
fp
)
fclose
(
fp
);
g_free
(
buffer
);
return
ret
;
}
struct
tag
*
tag_new
(
void
)
{
struct
tag
*
ret
=
g_new
(
struct
tag
,
1
);
...
...
src/tag.h
View file @
4a2b315a
...
...
@@ -61,8 +61,6 @@ struct tag {
unsigned
num_items
;
};
struct
tag
*
tag_ape_load
(
const
char
*
file
);
struct
tag
*
tag_new
(
void
);
void
tag_lib_init
(
void
);
...
...
src/tag_ape.c
0 → 100644
View file @
4a2b315a
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "tag_ape.h"
#include "tag.h"
#include <glib.h>
#include <stdio.h>
struct
tag
*
tag_ape_load
(
const
char
*
file
)
{
struct
tag
*
ret
=
NULL
;
FILE
*
fp
;
int
tagCount
;
char
*
buffer
=
NULL
;
char
*
p
;
size_t
tagLen
;
size_t
size
;
unsigned
long
flags
;
int
i
;
char
*
key
;
struct
{
unsigned
char
id
[
8
];
uint32_t
version
;
uint32_t
length
;
uint32_t
tagCount
;
unsigned
char
flags
[
4
];
unsigned
char
reserved
[
8
];
}
footer
;
const
char
*
apeItems
[
7
]
=
{
"title"
,
"artist"
,
"album"
,
"comment"
,
"genre"
,
"track"
,
"year"
};
int
tagItems
[
7
]
=
{
TAG_ITEM_TITLE
,
TAG_ITEM_ARTIST
,
TAG_ITEM_ALBUM
,
TAG_ITEM_COMMENT
,
TAG_ITEM_GENRE
,
TAG_ITEM_TRACK
,
TAG_ITEM_DATE
,
};
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
NULL
;
/* determine if file has an apeV2 tag */
if
(
fseek
(
fp
,
0
,
SEEK_END
))
goto
fail
;
size
=
(
size_t
)
ftell
(
fp
);
if
(
fseek
(
fp
,
size
-
sizeof
(
footer
),
SEEK_SET
))
goto
fail
;
if
(
fread
(
&
footer
,
1
,
sizeof
(
footer
),
fp
)
!=
sizeof
(
footer
))
goto
fail
;
if
(
memcmp
(
footer
.
id
,
"APETAGEX"
,
sizeof
(
footer
.
id
))
!=
0
)
goto
fail
;
if
(
GUINT32_FROM_LE
(
footer
.
version
)
!=
2000
)
goto
fail
;
/* find beginning of ape tag */
tagLen
=
GUINT32_FROM_LE
(
footer
.
length
);
if
(
tagLen
<
sizeof
(
footer
))
goto
fail
;
if
(
fseek
(
fp
,
size
-
tagLen
,
SEEK_SET
))
goto
fail
;
/* read tag into buffer */
tagLen
-=
sizeof
(
footer
);
if
(
tagLen
<=
0
)
goto
fail
;
buffer
=
g_malloc
(
tagLen
);
if
(
fread
(
buffer
,
1
,
tagLen
,
fp
)
!=
tagLen
)
goto
fail
;
/* read tags */
tagCount
=
GUINT32_FROM_LE
(
footer
.
tagCount
);
p
=
buffer
;
while
(
tagCount
--
&&
tagLen
>
10
)
{
size
=
GUINT32_FROM_LE
(
*
(
const
uint32_t
*
)
p
);
p
+=
4
;
tagLen
-=
4
;
flags
=
GUINT32_FROM_LE
(
*
(
const
uint32_t
*
)
p
);
p
+=
4
;
tagLen
-=
4
;
/* get the key */
key
=
p
;
while
(
tagLen
-
size
>
0
&&
*
p
!=
'\0'
)
{
p
++
;
tagLen
--
;
}
p
++
;
tagLen
--
;
/* get the value */
if
(
tagLen
<
size
)
goto
fail
;
/* we only care about utf-8 text tags */
if
(
!
(
flags
&
(
0x3
<<
1
)))
{
for
(
i
=
0
;
i
<
7
;
i
++
)
{
if
(
strcasecmp
(
key
,
apeItems
[
i
])
==
0
)
{
if
(
!
ret
)
ret
=
tag_new
();
tag_add_item_n
(
ret
,
tagItems
[
i
],
p
,
size
);
}
}
}
p
+=
size
;
tagLen
-=
size
;
}
fail:
if
(
fp
)
fclose
(
fp
);
g_free
(
buffer
);
return
ret
;
}
src/tag_ape.h
0 → 100644
View file @
4a2b315a
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MPD_TAG_APE_H
#define MPD_TAG_APE_H
/**
* Loads the APE tag from a file.
*
* @param path_fs the path of the file in filesystem encoding
* @return a tag object, or NULL if the file has no APE tag
*/
struct
tag
*
tag_ape_load
(
const
char
*
path_fs
);
#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