Commit 2001db8c authored by Avuton Olrich's avatar Avuton Olrich

Remove hosted libid3tag & libmad

git-svn-id: https://svn.musicpd.org/mpd/trunk@4369 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 939b40c4
......@@ -137,28 +137,6 @@ $AUTOMAKE --add-missing $AUTOMAKE_FLAGS
echo " autoconf"
autoconf
cd src/libid3tag
echo " [src/libid3tag] $ACLOCAL $ACLOCAL_FLAGS"
$ACLOCAL $ACLOCAL_FLAGS
echo " [src/libid3tag] autoheader"
autoheader
echo " [src/libid3tag] $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
$AUTOMAKE --add-missing $AUTOMAKE_FLAGS
echo " [src/libid3tag] autoconf"
autoconf
cd ../..
cd src/libmad
echo " [src/libmad] $ACLOCAL $ACLOCAL_FLAGS"
$ACLOCAL $ACLOCAL_FLAGS
echo " [src/libmad] autoheader"
autoheader
echo " [src/libmad] $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
$AUTOMAKE --add-missing $AUTOMAKE_FLAGS
echo " [src/libmad] autoconf"
autoconf
cd ../..
cd $olddir
if test x$NOCONFIGURE = x; then
$srcdir/configure "$@" && echo
......
dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(mpd, 0.10.0)
dnl AM_INIT_AUTOMAKE(mpd, 0.12.0)
AC_PREREQ(2.52)
AC_INIT(mpd, 0.12.0, warren.dukes@gmail.com)
......@@ -51,8 +51,6 @@ AC_ARG_ENABLE(audiofile,[ --disable-audiofile disable audiofile support, disabl
AC_ARG_ENABLE(mod,[ --enable-mod enable MOD support (default: disable],[enable_mod=$enableval],[enable_mod=yes])
AC_ARG_ENABLE(mpc,[ --disable-mpc disable musepack (MPC) support (default: enable)],[enable_mpc=$enableval],[enable_mpc=yes])
AC_ARG_ENABLE(id3,[ --disable-id3 disable id3 support (default: enable)],[enable_id3=$enableval],[enable_id3=yes])
AC_ARG_ENABLE(mpd_mad,[ --enable-mpd-mad use mpd libmad (default: disable)],[use_mpd_mad=$enableval],[use_mpd_mad=no])
AC_ARG_ENABLE(mpd_id3tag,[ --enable-mpd-id3tag use mpd libid3tag (default: disable)],[use_mpd_id3tag=$enableval],[use_mpd_id3tag=no])
AC_ARG_WITH(tremor,[[ --with-tremor[=PFX] Use Tremor(vorbisidec) integer Ogg-Vorbis decoder (with optional prefix)]], use_tremor=yes; test x$withval != xyes && tremor_prefix="$withval",)
AC_ARG_WITH(tremor-libraries,[ --with-tremor-libraries=DIR Directory where Tremor library is installed (optional)], tremor_libraries="$withval", tremor_libraries="")
......@@ -198,104 +196,84 @@ fi
ID3_SUBDIR=""
if test x$enable_id3 = xyes; then
if test x$use_mpd_id3tag = xyes; then
ID3_SUBDIR="libid3tag"
else
if test "x$id3tag_libraries" != "x" ; then
ID3TAG_LIBS="-L$id3tag_libraries"
elif test "x$id3tag_prefix" != "x" ; then
ID3TAG_LIBS="-L$id3tag_prefix/lib"
elif test "x$prefix" != "xNONE"; then
ID3TAG_LIBS="-L$libdir"
fi
ID3TAG_LIBS="$ID3TAG_LIBS -lid3tag -lz"
if test "x$id3tag_includes" != "x" ; then
ID3TAG_CFLAGS="-I$id3tag_includes"
elif test "x$id3tag_prefix" != "x" ; then
ID3TAG_CFLAGS="-I$id3tag_prefix/include"
elif test "x$prefix" != "xNONE"; then
ID3TAG_CFLAGS="-I$includedir"
fi
ID3TAG_CFLAGS="$ID3TAG_CFLAGS"
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $MPD_CFLAGS $ID3TAG_CFLAGS"
LIBS="$LIBS $MPD_LIBS $ID3TAG_LIBS"
CPPFLAGS=$CFLAGS
AC_CHECK_HEADERS(id3tag.h,use_libid3tag=yes,
[use_libid3tag=no;use_mpd_id3tag=yes])
if test x$use_libid3tag = xyes; then
AC_CHECK_LIB(id3tag,id3_file_open,
[ID3_LIB="$ID3TAG_LIBS";
MPD_CFLAGS="$MPD_CFLAGS $ID3TAG_CFLAGS";
use_libid3tag=yes],
[use_libid3tag=no;use_mpd_id3tag=yes])
fi
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
if test "x$id3tag_libraries" != "x" ; then
ID3TAG_LIBS="-L$id3tag_libraries"
elif test "x$id3tag_prefix" != "x" ; then
ID3TAG_LIBS="-L$id3tag_prefix/lib"
elif test "x$prefix" != "xNONE"; then
ID3TAG_LIBS="-L$libdir"
fi
ID3TAG_LIBS="$ID3TAG_LIBS -lid3tag -lz"
if test "x$id3tag_includes" != "x" ; then
ID3TAG_CFLAGS="-I$id3tag_includes"
elif test "x$id3tag_prefix" != "x" ; then
ID3TAG_CFLAGS="-I$id3tag_prefix/include"
elif test "x$prefix" != "xNONE"; then
ID3TAG_CFLAGS="-I$includedir"
fi
if test x$use_mpd_id3tag = xyes; then
AC_DEFINE(USE_MPD_ID3TAG,1,[Define to use mpd libid3tag])
ID3_LIB="libid3tag/libid3tag.la"
ID3_SUBDIR="libid3tag"
AC_CONFIG_SUBDIRS(src/libid3tag)
ID3TAG_CFLAGS="$ID3TAG_CFLAGS"
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $MPD_CFLAGS $ID3TAG_CFLAGS"
LIBS="$LIBS $MPD_LIBS $ID3TAG_LIBS"
CPPFLAGS=$CFLAGS
AC_CHECK_HEADERS(id3tag.h,use_libid3tag=yes,
[use_libid3tag=no])
if test x$use_libid3tag = xyes; then
AC_CHECK_LIB(id3tag,id3_file_open,
[ID3_LIB="$ID3TAG_LIBS";
MPD_CFLAGS="$MPD_CFLAGS $ID3TAG_CFLAGS";
use_libid3tag=yes],
[use_libid3tag=no])
fi
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
AC_DEFINE(HAVE_ID3TAG,1,[Define to use id3tag])
fi
MAD_SUBDIR=""
if test x$enable_mp3 = xyes; then
if test x$use_mpd_mad = xyes; then
MAD_SUBDIR="libmad"
else
if test "x$mad_libraries" != "x" ; then
MAD_LIBS="-L$mad_libraries"
elif test "x$mad_prefix" != "x" ; then
MAD_LIBS="-L$mad_prefix/lib"
elif test "x$prefix" != "xNONE"; then
MAD_LIBS="-L$libdir"
fi
MAD_LIBS="$MAD_LIBS -lmad"
if test "x$mad_includes" != "x" ; then
MAD_CFLAGS="-I$mad_includes"
elif test "x$mad_prefix" != "x" ; then
MAD_CFLAGS="-I$mad_prefix/include"
elif test "x$prefix" != "xNONE"; then
MAD_CFLAGS="-I$includedir"
fi
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $MPD_CFLAGS $MAD_CFLAGS"
LIBS="$LIBS $MPD_LIBS $MAD_LIBS"
CPPFLAGS=$CFLAGS
AC_CHECK_HEADERS(mad.h,use_libmad=yes,
[use_libmad=no;use_mpd_mad=yes])
if test x$use_libmad = xyes; then
AC_CHECK_LIB(mad,mad_stream_init,[MAD_LIB="$MAD_LIBS";
MPD_CFLAGS="$MPD_CFLAGS $MAD_CFLAGS";
use_libmad=yes],[use_libmad=no;use_mpd_mad=yes])
fi
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
if test "x$mad_libraries" != "x" ; then
MAD_LIBS="-L$mad_libraries"
elif test "x$mad_prefix" != "x" ; then
MAD_LIBS="-L$mad_prefix/lib"
elif test "x$prefix" != "xNONE"; then
MAD_LIBS="-L$libdir"
fi
if test x$use_mpd_mad = xyes; then
AC_DEFINE(USE_MPD_MAD,1,[Define to use mpd libmad])
MAD_LIB="libmad/libmad.la"
MAD_SUBDIR="libmad"
AC_CONFIG_SUBDIRS(src/libmad)
MAD_LIBS="$MAD_LIBS -lmad"
if test "x$mad_includes" != "x" ; then
MAD_CFLAGS="-I$mad_includes"
elif test "x$mad_prefix" != "x" ; then
MAD_CFLAGS="-I$mad_prefix/include"
elif test "x$prefix" != "xNONE"; then
MAD_CFLAGS="-I$includedir"
fi
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $MPD_CFLAGS $MAD_CFLAGS"
LIBS="$LIBS $MPD_LIBS $MAD_LIBS"
CPPFLAGS=$CFLAGS
AC_CHECK_HEADERS(mad.h,use_libmad=yes,
[use_libmad=no])
if test x$use_libmad = xyes; then
AC_CHECK_LIB(mad,mad_stream_init,[MAD_LIB="$MAD_LIBS";
MPD_CFLAGS="$MPD_CFLAGS $MAD_CFLAGS";
use_libmad=yes],[use_libmad=no])
fi
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
AC_DEFINE(HAVE_MAD,1,[Define to use libmad])
fi
......@@ -687,22 +665,12 @@ echo " File Format Support:"
if test x$enable_id3 = xyes; then
echo " ID3 tag support ...............enabled"
if test x$use_mpd_id3tag = xyes; then
echo " using MPD's libid3tag........yes"
else
echo " using MPD's libid3tag........no"
fi
else
echo " ID3 tag support ...............disabled"
fi
if test x$enable_mp3 = xyes; then
echo " mp3 support ...................enabled"
if test x$use_mpd_mad = xyes; then
echo " using MPD's libmad...........yes"
else
echo " using MPD's libmad...........no"
fi
else
echo " mp3 support ...................disabled"
fi
......
bin_PROGRAMS = mpd
SUBDIRS = $(ID3_SUBDIR) $(MAD_SUBDIR) $(MP4FF_SUBDIR)
SUBDIRS = $(MP4FF_SUBDIR)
mpd_audioOutputs = \
audioOutputs/audioOutput_alsa.c \
......@@ -115,4 +115,4 @@ mpd_SOURCES = \
mpd_CFLAGS = $(MPD_CFLAGS)
mpd_LDADD = $(MPD_LIBS) $(ID3_LIB) $(MAD_LIB) $(MP4FF_LIB)
DIST_SUBDIRS = mp4ff $(ID3_SUBDIR) $(MAD_SUBDIR)
DIST_SUBDIRS = mp4ff
......@@ -21,18 +21,12 @@
#ifdef HAVE_MAD
#include "../pcm_utils.h"
#ifdef USE_MPD_MAD
#include "../libmad/mad.h"
#else
#include <mad.h>
#endif
#ifdef HAVE_ID3TAG
#ifdef USE_MPD_ID3TAG
#include "../libid3tag/id3tag.h"
#else
#include <id3tag.h>
#endif
#endif
#include "../log.h"
#include "../utils.h"
#include "../replayGain.h"
......
libid3tag - ID3 tag manipulation library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
$Id: CHANGES,v 1.11 2004/02/17 02:04:10 rob Exp $
===============================================================================
Version 0.15.1 (beta)
* Updated to autoconf 2.59, automake 1.8.2, libtool 1.5.2.
* Fixed a potential problem in file.c when writing empty ID3v2 tags.
* Added new id3_field_gettextencoding() API routine.
Version 0.15.0 (beta)
* Updated to autoconf 2.57, automake 1.7.5, libtool 1.4.3.
* Added new id3_tag_version(), id3_tag_options(), id3_tag_setlength(),
id3_frame_field(), id3_field_getlatin1(), id3_field_getfulllatin1(),
id3_genre_index(), id3_genre_number(), id3_latin1_ucs4duplicate(),
id3_utf16_ucs4duplicate(), and id3_utf8_ucs4duplicate() API routines.
* Properly exposed the id3_frame_new(), id3_frame_delete(), and
id3_field_type() API routines.
* Fixed a possible segmentation fault rendering ID3v1 tags when a tag
field exceeds the field length limit.
* Fixed a problem whereby the file interface could try to seek and read
data from a non-seekable stream, unrecoverably losing data from the
stream. (N.B. the fix does not work under Win32.)
* Fixed a problem reading ID3v2.2 frames which corrupted their frame IDs
and caused them not to be re-rendered.
* Improved rendering of the ID3v1 genre field from ID3v2 genre
names/numbers. The genre "Other" is used in place of non-translatable
genres.
* Rendering an empty ID3v1 tag now properly returns 0 length even when a
null buffer pointer is passed.
* Changed the file implementation to maintain information about present
but unparseable tags, instead of ignoring all tags and returning an
error.
* Added an external dependency on zlib (libz), which is no longer
included.
* Changed to build a shared library by default.
* Changed to use native Cygwin build by default; give --host=mingw32 to
`configure' to use MinGW (and avoid a dependency on the Cygwin DLL).
Version 0.14.2 (beta)
* Changed Cygwin builds to use MinGW; resulting Win32 executables no
longer have a dependency on Cygwin DLLs.
Version 0.14.1 (beta)
* Updated config.guess and config.sub to latest upstream versions.
* Enabled libtool versioning rather than release numbering.
* Renamed `libid3' to `libid3tag' and enabled installation as a separate
library.
* Several other small fixes.
Version 0.14.0 (beta)
* Added a new ID3 tag manipulation library (libid3). The required zlib
support is provided either by the host system or by the included static
library implementation (libz).
* Improved MSVC++ portability and added MSVC++ project files.
===============================================================================
libid3tag - ID3 tag manipulation library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
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
If you would like to negotiate alternate licensing terms, you may do
so by contacting: Underbit Technologies, Inc. <info@underbit.com>
libid3tag - ID3 tag manipulation library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
$Id: CREDITS,v 1.2 2004/01/23 09:41:32 rob Exp $
===============================================================================
AUTHOR
Except where otherwise noted, all code was authored by:
Robert Leslie <rob@underbit.com>
CONTRIBUTORS
Significant contributions have been incorporated with thanks to:
Mark Malson <mark@mmalson.com>
2002/10/09: frame.c
- Reported problem reading ID3v2.2 tag frames.
Brett Paterson <brett@fmod.org>
2001/10/28: global.h
- Reported missing <assert.h> et al. under MS Embedded Visual C.
===============================================================================
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
##
## libid3tag - ID3 tag manipulation library
## Copyright (C) 2000-2004 Underbit Technologies, Inc.
##
## 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
##
## $Id: Makefile.am,v 1.26 2004/02/17 02:11:28 rob Exp $
##
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = foreign 1.6
SUBDIRS =
#DIST_SUBDIRS = msvc++
noinst_LTLIBRARIES = libid3tag.la
noinst_HEADERS = id3tag.h
## From the libtool documentation on library versioning:
##
## CURRENT
## The most recent interface number that this library implements.
##
## REVISION
## The implementation number of the CURRENT interface.
##
## AGE
## The difference between the newest and oldest interfaces that this
## library implements. In other words, the library implements all the
## interface numbers in the range from number `CURRENT - AGE' to
## `CURRENT'.
##
## If two libraries have identical CURRENT and AGE numbers, then the
## dynamic linker chooses the library with the greater REVISION number.
##
## 1. Start with version information of `0:0:0' for each libtool library.
##
## 2. Update the version information only immediately before a public
## release of your software. More frequent updates are unnecessary,
## and only guarantee that the current interface number gets larger
## faster.
##
## 3. If the library source code has changed at all since the last
## update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
##
## 4. If any interfaces have been added, removed, or changed since the
## last update, increment CURRENT, and set REVISION to 0.
##
## 5. If any interfaces have been added since the last public release,
## then increment AGE.
##
## 6. If any interfaces have been removed since the last public release,
## then set AGE to 0.
version_current = 3
version_revision = 0
version_age = 3
version_info = $(version_current):$(version_revision):$(version_age)
EXTRA_DIST = genre.dat.sed \
CHANGES COPYRIGHT CREDITS README TODO VERSION
if DEBUG
debug = debug.c debug.h
else
debug =
endif
libid3tag_la_SOURCES = version.c ucs4.c latin1.c utf16.c utf8.c \
parse.c render.c field.c frametype.c compat.c \
genre.c frame.c crc.c util.c tag.c file.c \
version.h ucs4.h latin1.h utf16.h utf8.h \
parse.h render.h field.h frametype.h compat.h \
genre.h frame.h crc.h util.h tag.h file.h \
id3tag.h global.h genre.dat $(debug)
EXTRA_libid3tag_la_SOURCES = \
frametype.gperf compat.gperf genre.dat.in \
debug.c debug.h
#libid3tag_la_LDFLAGS = -version-info $(version_info)
BUILT_SOURCES = frametype.c compat.c genre.dat
$(srcdir)/frametype.c: $(srcdir)/frametype.gperf Makefile.am
cd $(srcdir) && \
gperf -tCcTonD -K id -N id3_frametype_lookup -s -3 -k '*' \
frametype.gperf | \
sed -e 's/\(struct id3_frametype\);/\1/' | \
sed -e '/\$$''Id: /s/\$$//g' >frametype.c
$(srcdir)/compat.c: $(srcdir)/compat.gperf Makefile.am
cd $(srcdir) && \
gperf -tCcTonD -K id -N id3_compat_lookup -s -3 -k '*' \
compat.gperf | \
sed -e 's/\(struct id3_compat\);/\1/' | \
sed -e '/\$$''Id: /s/\$$//g' >compat.c
$(srcdir)/genre.dat: $(srcdir)/genre.dat.in $(srcdir)/genre.dat.sed Makefile.am
cd $(srcdir) && \
sed -n -f genre.dat.sed genre.dat.in | \
sed -e '/\$$''Id: /s/\$$//g' >genre.dat
libtool: $(LIBTOOL_DEPS)
$(SHELL) ./config.status --recheck
again:
$(MAKE) clean
$(MAKE)
.PHONY: again
libid3tag - ID3 tag manipulation library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
$Id: README,v 1.5 2004/01/23 09:41:32 rob Exp $
===============================================================================
INTRODUCTION
libid3tag is a library for reading and (eventually) writing ID3 tags, both
ID3v1 and the various versions of ID3v2.
See the file `id3tag.h' for the current library interface.
This package uses GNU libtool to arrange for zlib to be linked
automatically when you link your programs with this library. If you aren't
using GNU libtool, in some cases you may need to link with zlib
explicitly:
${link_command} ... -lid3tag -lz
===============================================================================
BUILDING AND INSTALLING
Note that this library depends on zlib 1.1.4 or later. If you don't have
zlib already, you can obtain it from:
http://www.gzip.org/zlib/
You must have zlib installed before you can build this package.
Windows Platforms
libid3tag can be built under Windows using either MSVC++ or Cygwin. A
MSVC++ project file can be found under the `msvc++' subdirectory.
To build libid3tag using Cygwin, you will first need to install the Cygwin
tools:
http://www.cygwin.com/
You may then proceed with the following POSIX instructions within the
Cygwin shell.
Note that by default Cygwin will build a library that depends on the
Cygwin DLL. You can use MinGW to build a library that does not depend on
the Cygwin DLL. To do so, give the option --host=mingw32 to `configure'.
Be certain you also link with a MinGW version of zlib.
POSIX Platforms (including Cygwin)
The code is distributed with a `configure' script that will generate for
you a `Makefile' and a `config.h' for your platform. See the file
`INSTALL' for generic instructions.
The specific options you may want to give `configure' are:
--disable-debugging do not compile with debugging support, and
use more optimizations
--disable-shared do not build a shared library
By default the package will build a shared library if possible for your
platform. If you want only a static library, use --disable-shared.
If zlib is installed in an unusual place or `configure' can't find it, you
may need to indicate where it is:
./configure ... CPPFLAGS="-I${include_dir}" LDFLAGS="-L${lib_dir}"
where ${include_dir} and ${lib_dir} are the locations of the installed
header and library files, respectively.
Experimenting and Developing
Further options for `configure' that may be useful to developers and
experimenters are:
--enable-debugging enable diagnostic debugging support and
debugging symbols
--enable-profiling generate `gprof' profiling code
===============================================================================
COPYRIGHT
Please read the `COPYRIGHT' file for copyright and warranty information.
Also, the file `COPYING' contains the full text of the GNU GPL.
Send inquiries, comments, bug reports, suggestions, patches, etc. to:
Underbit Technologies, Inc. <support@underbit.com>
See also the MAD home page on the Web:
http://www.underbit.com/products/mad/
===============================================================================
libid3tag - ID3 tag manipulation library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
$Id: TODO,v 1.2 2004/01/23 09:41:32 rob Exp $
===============================================================================
libid3tag:
- finish file API
- fix API headers
0.15.1b
configure.ac:24
id3tag.h:338-341
msvc++/config.h:59,65,71
Makefile.am:63-65
%{
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: compat.gperf,v 1.11 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <stdlib.h>
# include <string.h>
# ifdef HAVE_ASSERT_H
# include <assert.h>
# endif
# include "id3tag.h"
# include "compat.h"
# include "frame.h"
# include "field.h"
# include "parse.h"
# include "ucs4.h"
# define EQ(id) #id, 0
# define OBSOLETE 0, 0
# define TX(id) #id, translate_##id
static id3_compat_func_t translate_TCON;
%}
struct id3_compat;
%%
#
# ID3v2.2 and ID3v2.3 frames
#
# Only obsolete frames or frames with an equivalent ID3v2.4 frame ID are
# listed here. If a frame ID is not listed, it is assumed that the same
# frame ID is itself the equivalent ID3v2.4 frame ID.
#
# This list may also include frames with new content interpretations; the
# translation function will rewrite the contents to comply with ID3v2.4.
#
BUF, EQ(RBUF) /* Recommended buffer size */
CNT, EQ(PCNT) /* Play counter */
COM, EQ(COMM) /* Comments */
CRA, EQ(AENC) /* Audio encryption */
CRM, OBSOLETE /* Encrypted meta frame [obsolete] */
EQU, OBSOLETE /* Equalization [obsolete] */
EQUA, OBSOLETE /* Equalization [obsolete] */
ETC, EQ(ETCO) /* Event timing codes */
GEO, EQ(GEOB) /* General encapsulated object */
IPL, EQ(TIPL) /* Involved people list */
IPLS, EQ(TIPL) /* Involved people list */
LNK, EQ(LINK) /* Linked information */
MCI, EQ(MCDI) /* Music CD identifier */
MLL, EQ(MLLT) /* MPEG location lookup table */
PIC, EQ(APIC) /* Attached picture */
POP, EQ(POPM) /* Popularimeter */
REV, EQ(RVRB) /* Reverb */
RVA, OBSOLETE /* Relative volume adjustment [obsolete] */
RVAD, OBSOLETE /* Relative volume adjustment [obsolete] */
SLT, EQ(SYLT) /* Synchronised lyric/text */
STC, EQ(SYTC) /* Synchronised tempo codes */
TAL, EQ(TALB) /* Album/movie/show title */
TBP, EQ(TBPM) /* BPM (beats per minute) */
TCM, EQ(TCOM) /* Composer */
TCO, TX(TCON) /* Content type */
TCON, TX(TCON) /* Content type */
TCR, EQ(TCOP) /* Copyright message */
TDA, OBSOLETE /* Date [obsolete] */
TDAT, OBSOLETE /* Date [obsolete] */
TDY, EQ(TDLY) /* Playlist delay */
TEN, EQ(TENC) /* Encoded by */
TFT, EQ(TFLT) /* File type */
TIM, OBSOLETE /* Time [obsolete] */
TIME, OBSOLETE /* Time [obsolete] */
TKE, EQ(TKEY) /* Initial key */
TLA, EQ(TLAN) /* Language(s) */
TLE, EQ(TLEN) /* Length */
TMT, EQ(TMED) /* Media type */
TOA, EQ(TOPE) /* Original artist(s)/performer(s) */
TOF, EQ(TOFN) /* Original filename */
TOL, EQ(TOLY) /* Original lyricist(s)/text writer(s) */
TOR, EQ(TDOR) /* Original release year [obsolete] */
TORY, EQ(TDOR) /* Original release year [obsolete] */
TOT, EQ(TOAL) /* Original album/movie/show title */
TP1, EQ(TPE1) /* Lead performer(s)/soloist(s) */
TP2, EQ(TPE2) /* Band/orchestra/accompaniment */
TP3, EQ(TPE3) /* Conductor/performer refinement */
TP4, EQ(TPE4) /* Interpreted, remixed, or otherwise modified by */
TPA, EQ(TPOS) /* Part of a set */
TPB, EQ(TPUB) /* Publisher */
TRC, EQ(TSRC) /* ISRC (international standard recording code) */
TRD, OBSOLETE /* Recording dates [obsolete] */
TRDA, OBSOLETE /* Recording dates [obsolete] */
TRK, EQ(TRCK) /* Track number/position in set */
TSI, OBSOLETE /* Size [obsolete] */
TSIZ, OBSOLETE /* Size [obsolete] */
TSS, EQ(TSSE) /* Software/hardware and settings used for encoding */
TT1, EQ(TIT1) /* Content group description */
TT2, EQ(TIT2) /* Title/songname/content description */
TT3, EQ(TIT3) /* Subtitle/description refinement */
TXT, EQ(TEXT) /* Lyricist/text writer */
TXX, EQ(TXXX) /* User defined text information frame */
TYE, OBSOLETE /* Year [obsolete] */
TYER, OBSOLETE /* Year [obsolete] */
UFI, EQ(UFID) /* Unique file identifier */
ULT, EQ(USLT) /* Unsynchronised lyric/text transcription */
WAF, EQ(WOAF) /* Official audio file webpage */
WAR, EQ(WOAR) /* Official artist/performer webpage */
WAS, EQ(WOAS) /* Official audio source webpage */
WCM, EQ(WCOM) /* Commercial information */
WCP, EQ(WCOP) /* Copyright/legal information */
WPB, EQ(WPUB) /* Publishers official webpage */
WXX, EQ(WXXX) /* User defined URL link frame */
%%
static
int translate_TCON(struct id3_frame *frame, char const *oldid,
id3_byte_t const *data, id3_length_t length)
{
id3_byte_t const *end;
enum id3_field_textencoding encoding;
id3_ucs4_t *string = 0, *ptr, *endptr;
int result = 0;
/* translate old TCON syntax into multiple strings */
assert(frame->nfields == 2);
encoding = ID3_FIELD_TEXTENCODING_ISO_8859_1;
end = data + length;
if (id3_field_parse(&frame->fields[0], &data, end - data, &encoding) == -1)
goto fail;
string = id3_parse_string(&data, end - data, encoding, 0);
if (string == 0)
goto fail;
ptr = string;
while (*ptr == '(') {
if (*++ptr == '(')
break;
endptr = ptr;
while (*endptr && *endptr != ')')
++endptr;
if (*endptr)
*endptr++ = 0;
if (id3_field_addstring(&frame->fields[1], ptr) == -1)
goto fail;
ptr = endptr;
}
if (*ptr && id3_field_addstring(&frame->fields[1], ptr) == -1)
goto fail;
if (0) {
fail:
result = -1;
}
if (string)
free(string);
return result;
}
/*
* NAME: compat->fixup()
* DESCRIPTION: finish compatibility translations
*/
int id3_compat_fixup(struct id3_tag *tag)
{
struct id3_frame *frame;
unsigned int index;
id3_ucs4_t timestamp[17] = { 0 };
int result = 0;
/* create a TDRC frame from obsolete TYER/TDAT/TIME frames */
/*
* TYE/TYER: YYYY
* TDA/TDAT: DDMM
* TIM/TIME: HHMM
*
* TDRC: yyyy-MM-ddTHH:mm
*/
index = 0;
while ((frame = id3_tag_findframe(tag, ID3_FRAME_OBSOLETE, index++))) {
char const *id;
id3_byte_t const *data, *end;
id3_length_t length;
enum id3_field_textencoding encoding;
id3_ucs4_t *string;
id = id3_field_getframeid(&frame->fields[0]);
assert(id);
if (strcmp(id, "TYER") != 0 && strcmp(id, "YTYE") != 0 &&
strcmp(id, "TDAT") != 0 && strcmp(id, "YTDA") != 0 &&
strcmp(id, "TIME") != 0 && strcmp(id, "YTIM") != 0)
continue;
data = id3_field_getbinarydata(&frame->fields[1], &length);
assert(data);
if (length < 1)
continue;
end = data + length;
encoding = id3_parse_uint(&data, 1);
string = id3_parse_string(&data, end - data, encoding, 0);
if (id3_ucs4_length(string) < 4) {
free(string);
continue;
}
if (strcmp(id, "TYER") == 0 ||
strcmp(id, "YTYE") == 0) {
timestamp[0] = string[0];
timestamp[1] = string[1];
timestamp[2] = string[2];
timestamp[3] = string[3];
}
else if (strcmp(id, "TDAT") == 0 ||
strcmp(id, "YTDA") == 0) {
timestamp[4] = '-';
timestamp[5] = string[2];
timestamp[6] = string[3];
timestamp[7] = '-';
timestamp[8] = string[0];
timestamp[9] = string[1];
}
else { /* TIME or YTIM */
timestamp[10] = 'T';
timestamp[11] = string[0];
timestamp[12] = string[1];
timestamp[13] = ':';
timestamp[14] = string[2];
timestamp[15] = string[3];
}
free(string);
}
if (timestamp[0]) {
id3_ucs4_t *strings;
frame = id3_frame_new("TDRC");
if (frame == 0)
goto fail;
strings = timestamp;
if (id3_field_settextencoding(&frame->fields[0],
ID3_FIELD_TEXTENCODING_ISO_8859_1) == -1 ||
id3_field_setstrings(&frame->fields[1], 1, &strings) == -1 ||
id3_tag_attachframe(tag, frame) == -1) {
id3_frame_delete(frame);
goto fail;
}
}
if (0) {
fail:
result = -1;
}
return result;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: compat.h,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_COMPAT_H
# define LIBID3TAG_COMPAT_H
# include "id3tag.h"
typedef int id3_compat_func_t(struct id3_frame *, char const *,
id3_byte_t const *, id3_length_t);
struct id3_compat {
char const *id;
char const *equiv;
id3_compat_func_t *translate;
};
struct id3_compat const *id3_compat_lookup(register char const *,
register unsigned int);
int id3_compat_fixup(struct id3_tag *);
# endif
dnl -*- m4 -*-
dnl
dnl libid3tag - ID3 tag manipulation library
dnl Copyright (C) 2000-2004 Underbit Technologies, Inc.
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
AC_REVISION([$Id: configure.ac,v 1.12 2004/01/23 23:22:46 rob Exp $])dnl
dnl Process this file with autoconf to produce a configure script.
AC_INIT([ID3 Tag], [0.15.1b], [support@underbit.com], [libid3tag])
AC_PREREQ(2.53)
AC_CONFIG_SRCDIR([id3tag.h])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h])
dnl System type.
AC_CANONICAL_HOST
dnl Checks for programs.
AC_PROG_CC
if test "$GCC" = yes
then
case "$host" in
*-*-mingw*)
case "$build" in
*-*-cygwin*)
CPPFLAGS="$CPPFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
;;
esac
esac
dnl case "$host" in
dnl *-*-cygwin* | *-*-mingw*)
dnl LDFLAGS="$LDFLAGS -no-undefined -mdll"
dnl ;;
dnl esac
fi
dnl Support for libtool.
AC_DISABLE_SHARED
dnl AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
dnl Compiler options.
arch=""
debug=""
optimize=""
profile=""
set -- $CFLAGS
CFLAGS=""
if test "$GCC" = yes
then
CFLAGS="-Wall"
fi
while test $# -gt 0
do
case "$1" in
-Wall)
if test "$GCC" = yes
then
:
else
CFLAGS="$CFLAGS $1"
fi
shift
;;
-g)
debug="-g"
shift
;;
-mno-cygwin)
shift
;;
-m*)
arch="$arch $1"
shift
;;
-fomit-frame-pointer)
shift
;;
-O*|-f*)
optimize="$1"
shift
;;
*)
CFLAGS="$CFLAGS $1"
shift
;;
esac
done
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(assert.h unistd.h)
AC_CHECK_HEADER(zlib.h, [], [
AC_MSG_ERROR([zlib.h was not found
*** You must first install zlib (libz) before you can build this package.
*** If zlib is already installed, you may need to use the CPPFLAGS
*** environment variable to specify its installed location, e.g. -I<dir>.])
])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
dnl Checks for library functions.
AC_CHECK_FUNCS(ftruncate)
AC_CHECK_LIB(z, compress2, [], [
AC_MSG_ERROR([libz was not found
*** You must first install zlib (libz) before you can build this package.
*** If zlib is already installed, you may need to use the LDFLAGS
*** environment variable to specify its installed location, e.g. -L<dir>.])
])
dnl handle --enable and --disable options
AC_CACHE_SAVE
AC_MSG_CHECKING([whether to enable profiling])
AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling],
[generate profiling code]),
[
case "$enableval" in
yes) profile="-pg" ;;
esac
])
AC_MSG_RESULT(${enable_profiling-no})
AC_MSG_CHECKING([whether to enable debugging])
AC_ARG_ENABLE(debugging, AC_HELP_STRING([--enable-debugging],
[enable diagnostic debugging support])
AC_HELP_STRING([--disable-debugging],
[do not enable debugging and use more optimization]),
[
case "$enableval" in
yes)
AC_DEFINE(DEBUG, 1,
[Define to enable diagnostic debugging support.])
optimize=""
;;
no)
if test -n "$profile"
then
AC_MSG_ERROR(--enable-profiling and --disable-debugging are incompatible)
fi
AC_DEFINE(NDEBUG, 1,
[Define to disable debugging assertions.])
debug=""
if test "$GCC" = yes
then
optimize="$optimize -fomit-frame-pointer"
fi
;;
esac
])
AC_MSG_RESULT(${enable_debugging-default})
AM_CONDITIONAL(DEBUG, test ${enable_debugging-default} = yes)
dnl Create output files.
test -n "$arch" && CFLAGS="$CFLAGS $arch"
test -n "$debug" && CFLAGS="$CFLAGS $debug"
test -n "$optimize" && CFLAGS="$CFLAGS $optimize"
test -n "$profile" && CFLAGS="$CFLAGS $profile" LDFLAGS="$LDFLAGS $profile"
dnl LTLIBOBJS=`echo "$LIBOBJS" | sed -e 's/\.o/.lo/g'`
dnl AC_SUBST(LTLIBOBJS)
AC_CONFIG_FILES([Makefile \
libid3tag.list])
AC_OUTPUT
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: crc.c,v 1.11 2004/02/17 02:04:10 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include "id3tag.h"
# include "crc.h"
static
unsigned long const crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL,
0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L,
0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L,
0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L,
0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL,
0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L,
0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L,
0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L,
0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L,
0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L,
0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL,
0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL,
0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL,
0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L,
0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L,
0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL,
0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L,
0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL,
0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L,
0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL,
0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L,
0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L,
0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L,
0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L,
0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL,
0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL,
0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L,
0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L,
0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL,
0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L,
0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL,
0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L,
0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL,
0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L,
0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L,
0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL,
0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L,
0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL,
0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL,
0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L,
0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L,
0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL,
0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L,
0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L,
0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L,
0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL,
0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L,
0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L,
0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL,
0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L,
0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL
};
/*
* NAME: crc->compute()
* DESCRIPTION: calculate CRC-32 value (ISO 3309)
*/
unsigned long id3_crc_compute(id3_byte_t const *data, id3_length_t length)
{
register unsigned long crc;
for (crc = 0xffffffffL; length >= 8; length -= 8) {
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
}
switch (length) {
case 7: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 6: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 5: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 4: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 3: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 2: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 1: crc = crc_table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
case 0: break;
}
return crc ^ 0xffffffffL;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: crc.h,v 1.8 2004/02/17 02:04:10 rob Exp $
*/
# ifndef LIBID3TAG_CRC_H
# define LIBID3TAG_CRC_H
# include "id3tag.h"
unsigned long id3_crc_compute(id3_byte_t const *, id3_length_t);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: debug.c,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# undef malloc
# undef calloc
# undef realloc
# undef free
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include "debug.h"
# if defined(DEBUG)
# define DEBUG_MAGIC 0xdeadbeefL
struct debug {
char const *file;
unsigned int line;
size_t size;
struct debug *next;
struct debug *prev;
long int magic;
};
static struct debug *allocated;
static int registered;
static
void check(void)
{
struct debug *debug;
for (debug = allocated; debug; debug = debug->next) {
if (debug->magic != DEBUG_MAGIC) {
fprintf(stderr, "memory corruption\n");
break;
}
fprintf(stderr, "%s:%u: leaked %lu bytes\n",
debug->file, debug->line, debug->size);
}
}
void *id3_debug_malloc(size_t size, char const *file, unsigned int line)
{
struct debug *debug;
if (!registered) {
atexit(check);
registered = 1;
}
if (size == 0)
fprintf(stderr, "%s:%u: malloc(0)\n", file, line);
debug = malloc(sizeof(*debug) + size);
if (debug == 0) {
fprintf(stderr, "%s:%u: malloc(%lu) failed\n", file, line, size);
return 0;
}
debug->magic = DEBUG_MAGIC;
debug->file = file;
debug->line = line;
debug->size = size;
debug->next = allocated;
debug->prev = 0;
if (allocated)
allocated->prev = debug;
allocated = debug;
return ++debug;
}
void *id3_debug_calloc(size_t nmemb, size_t size,
char const *file, unsigned int line)
{
void *ptr;
ptr = id3_debug_malloc(nmemb * size, file, line);
if (ptr)
memset(ptr, 0, nmemb * size);
return ptr;
}
void *id3_debug_realloc(void *ptr, size_t size,
char const *file, unsigned int line)
{
struct debug *debug, *new;
if (size == 0) {
id3_debug_free(ptr, file, line);
return 0;
}
if (ptr == 0)
return id3_debug_malloc(size, file, line);
debug = ptr;
--debug;
if (debug->magic != DEBUG_MAGIC) {
fprintf(stderr, "%s:%u: realloc(%p, %lu) memory not allocated\n",
file, line, ptr, size);
return 0;
}
new = realloc(debug, sizeof(*debug) + size);
if (new == 0) {
fprintf(stderr, "%s:%u: realloc(%p, %lu) failed\n", file, line, ptr, size);
return 0;
}
if (allocated == debug)
allocated = new;
debug = new;
debug->file = file;
debug->line = line;
debug->size = size;
if (debug->next)
debug->next->prev = debug;
if (debug->prev)
debug->prev->next = debug;
return ++debug;
}
void id3_debug_free(void *ptr, char const *file, unsigned int line)
{
struct debug *debug;
if (ptr == 0) {
fprintf(stderr, "%s:%u: free(0)\n", file, line);
return;
}
debug = ptr;
--debug;
if (debug->magic != DEBUG_MAGIC) {
fprintf(stderr, "%s:%u: free(%p) memory not allocated\n", file, line, ptr);
return;
}
debug->magic = 0;
if (debug->next)
debug->next->prev = debug->prev;
if (debug->prev)
debug->prev->next = debug->next;
if (allocated == debug)
allocated = debug->next;
free(debug);
}
void *id3_debug_release(void *ptr, char const *file, unsigned int line)
{
struct debug *debug;
if (ptr == 0)
return 0;
debug = ptr;
--debug;
if (debug->magic != DEBUG_MAGIC) {
fprintf(stderr, "%s:%u: release(%p) memory not allocated\n",
file, line, ptr);
return ptr;
}
if (debug->next)
debug->next->prev = debug->prev;
if (debug->prev)
debug->prev->next = debug->next;
if (allocated == debug)
allocated = debug->next;
memmove(debug, debug + 1, debug->size);
return debug;
}
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: debug.h,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_DEBUG_H
# define LIBID3TAG_DEBUG_H
# include <stdlib.h>
void *id3_debug_malloc(size_t, char const *, unsigned int);
void *id3_debug_calloc(size_t, size_t, char const *, unsigned int);
void *id3_debug_realloc(void *, size_t, char const *, unsigned int);
void id3_debug_free(void *, char const *, unsigned int);
void *id3_debug_release(void *, char const *, unsigned int);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: field.h,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_FIELD_H
# define LIBID3TAG_FIELD_H
# include "id3tag.h"
void id3_field_init(union id3_field *, enum id3_field_type);
void id3_field_finish(union id3_field *);
int id3_field_parse(union id3_field *, id3_byte_t const **,
id3_length_t, enum id3_field_textencoding *);
id3_length_t id3_field_render(union id3_field const *, id3_byte_t **,
enum id3_field_textencoding *, int);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: file.h,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_FILE_H
# define LIBID3TAG_FILE_H
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: frame.h,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_FRAME_H
# define LIBID3TAG_FRAME_H
# include "id3tag.h"
int id3_frame_validid(char const *);
void id3_frame_addref(struct id3_frame *);
void id3_frame_delref(struct id3_frame *);
struct id3_frame *id3_frame_parse(id3_byte_t const **, id3_length_t,
unsigned int);
id3_length_t id3_frame_render(struct id3_frame const *, id3_byte_t **, int);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: frametype.h,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_FRAMETYPE_H
# define LIBID3TAG_FRAMETYPE_H
struct id3_frametype {
char const *id;
unsigned int nfields;
enum id3_field_type const *fields;
int defaultflags;
char const *description;
};
extern struct id3_frametype const id3_frametype_text;
extern struct id3_frametype const id3_frametype_url;
extern struct id3_frametype const id3_frametype_experimental;
extern struct id3_frametype const id3_frametype_unknown;
extern struct id3_frametype const id3_frametype_obsolete;
struct id3_frametype const *id3_frametype_lookup(register char const *,
register unsigned int);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: genre.c,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include "id3tag.h"
# include "ucs4.h"
/* genres are stored in ucs4 format */
# include "genre.dat"
# define NGENRES (sizeof(genre_table) / sizeof(genre_table[0]))
/*
* NAME: genre->index()
* DESCRIPTION: return an ID3v1 genre string indexed by number
*/
id3_ucs4_t const *id3_genre_index(unsigned int index)
{
return (index < NGENRES) ? genre_table[index] : 0;
}
/*
* NAME: genre->name()
* DESCRIPTION: translate an ID3v2 genre number/keyword to its full name
*/
id3_ucs4_t const *id3_genre_name(id3_ucs4_t const *string)
{
id3_ucs4_t const *ptr;
static id3_ucs4_t const genre_remix[] = { 'R', 'e', 'm', 'i', 'x', 0 };
static id3_ucs4_t const genre_cover[] = { 'C', 'o', 'v', 'e', 'r', 0 };
unsigned long number;
if (string == 0 || *string == 0)
return id3_ucs4_empty;
if (string[0] == 'R' && string[1] == 'X' && string[2] == 0)
return genre_remix;
if (string[0] == 'C' && string[1] == 'R' && string[2] == 0)
return genre_cover;
for (ptr = string; *ptr; ++ptr) {
if (*ptr < '0' || *ptr > '9')
return string;
}
number = id3_ucs4_getnumber(string);
return (number < NGENRES) ? genre_table[number] : string;
}
/*
* NAME: translate()
* DESCRIPTION: return a canonicalized character for testing genre equivalence
*/
static
id3_ucs4_t translate(id3_ucs4_t ch)
{
if (ch) {
if (ch >= 'A' && ch <= 'Z')
ch += 'a' - 'A';
if (ch < 'a' || ch > 'z')
ch = ID3_UCS4_REPLACEMENTCHAR;
}
return ch;
}
/*
* NAME: compare()
* DESCRIPTION: test two ucs4 genre strings for equivalence
*/
static
int compare(id3_ucs4_t const *str1, id3_ucs4_t const *str2)
{
id3_ucs4_t c1, c2;
if (str1 == str2)
return 1;
do {
do
c1 = translate(*str1++);
while (c1 == ID3_UCS4_REPLACEMENTCHAR);
do
c2 = translate(*str2++);
while (c2 == ID3_UCS4_REPLACEMENTCHAR);
}
while (c1 && c1 == c2);
return c1 == c2;
}
/*
* NAME: genre->number()
* DESCRIPTION: translate an ID3v2 genre name/number to its ID3v1 index number
*/
int id3_genre_number(id3_ucs4_t const *string)
{
id3_ucs4_t const *ptr;
int i;
if (string == 0 || *string == 0)
return -1;
for (ptr = string; *ptr; ++ptr) {
if (*ptr < '0' || *ptr > '9')
break;
}
if (*ptr == 0) {
unsigned long number;
number = id3_ucs4_getnumber(string);
return (number <= 0xff) ? number : -1;
}
for (i = 0; i < NGENRES; ++i) {
if (compare(string, genre_table[i]))
return i;
}
/* no equivalent */
return -1;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: genre.dat.in,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
/*
* These are the ID3 genre names, taken as a combination of names from ID3v1
* (listed in Appendix A of the ID3 tag version 2.4.0 informal standard) and
* the extensions made by Winamp as of version 2.80.
*/
/* ID3v1 names (0-79) */
Blues
Classic Rock
Country
Dance
Disco
Funk
Grunge
Hip-Hop
Jazz
Metal
New Age
Oldies
Other
Pop
R&B
Rap
Reggae
Rock
Techno
Industrial
Alternative
Ska
Death Metal
Pranks
Soundtrack
Euro-Techno
Ambient
Trip-Hop
Vocal
Jazz+Funk
Fusion
Trance
Classical
Instrumental
Acid
House
Game
Sound Clip
Gospel
Noise
AlternRock
Bass
Soul
Punk
Space
Meditative
Instrumental Pop
Instrumental Rock
Ethnic
Gothic
Darkwave
Techno-Industrial
Electronic
Pop-Folk
Eurodance
Dream
Southern Rock
Comedy
Cult
Gangsta
Top 40
Christian Rap
Pop/Funk
Jungle
Native American
Cabaret
New Wave
Psychedelic
Rave
Showtunes
Trailer
Lo-Fi
Tribal
Acid Punk
Acid Jazz
Polka
Retro
Musical
Rock & Roll
Hard Rock
/* Winamp extensions (80-147) */
Folk
Folk/Rock
National Folk
Swing
Fast-Fusion
Bebob
Latin
Revival
Celtic
Bluegrass
Avantgarde
Gothic Rock
Progressive Rock
Psychedelic Rock
Symphonic Rock
Slow Rock
Big Band
Chorus
Easy Listening
Acoustic
Humour
Speech
Chanson
Opera
Chamber Music
Sonata
Symphony
Booty Bass
Primus
Porn Groove
Satire
Slow Jam
Club
Tango
Samba
Folklore
Ballad
Power Ballad
Rhythmic Soul
Freestyle
Duet
Punk Rock
Drum Solo
A Cappella
Euro-House
Dance Hall
Goa
Drum & Bass
Club-House
Hardcore
Terror
Indie
BritPop
Negerpunk
Polsk Punk
Beat
Christian Gangsta Rap
Heavy Metal
Black Metal
Crossover
Contemporary Christian
Christian Rock
Merengue
Salsa
Thrash Metal
Anime
JPop
Synthpop
#
# libid3tag - ID3 tag manipulation library
# Copyright (C) 2000-2004 Underbit Technologies, Inc.
#
# 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
#
# $Id: genre.dat.sed,v 1.10 2004/01/23 09:41:32 rob Exp $
#
1i\
/* Automatically generated from genre.dat.in */
# generate an array from a string
/^[A-Za-z]/{
H
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s/[^A-Z0-9]/_/g
s/.*/static id3_ucs4_t const genre_&[] =/p
g
s/.*\n//
s/./'&', /g
s/.*/ { &0 };/
}
# write the final table of arrays
${
p
i\
\
static id3_ucs4_t const *const genre_table[] = {
g
s/^\(\n\)\(.*\)$/\2\1/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s/[^A-Z0-9\n]/_/g
s/\([^\n]*\)\(\n\)/ genre_\1,\2/g
s/,\n$//
a\
};
}
# print the pattern space (assumes -n)
p
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: genre.h,v 1.6 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_GENRE_H
# define LIBID3TAG_GENRE_H
# define ID3_GENRE_OTHER 12
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: global.h,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_GLOBAL_H
# define LIBID3TAG_GLOBAL_H
/* conditional debugging */
# if defined(DEBUG) && defined(NDEBUG)
# error "cannot define both DEBUG and NDEBUG"
# endif
# if defined(DEBUG)
# include <stdio.h>
# include "debug.h"
# define malloc(sz) id3_debug_malloc(sz, __FILE__, __LINE__)
# define calloc(n, sz) id3_debug_calloc(n, sz, __FILE__, __LINE__)
# define realloc(ptr, sz) id3_debug_realloc(ptr, sz, __FILE__, __LINE__)
# define free(ptr) id3_debug_free(ptr, __FILE__, __LINE__)
# define release(ptr) id3_debug_release(ptr, __FILE__, __LINE__)
# else
# define release(ptr) (ptr)
# endif
/* conditional features */
# if !defined(HAVE_ASSERT_H)
# if defined(NDEBUG)
# define assert(x) /* nothing */
# else
# define assert(x) do { if (!(x)) abort(); } while (0)
# endif
# endif
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: latin1.c,v 1.10 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <stdlib.h>
# include "id3tag.h"
# include "latin1.h"
# include "ucs4.h"
/*
* NAME: latin1->length()
* DESCRIPTION: return the number of ucs4 chars represented by a latin1 string
*/
id3_length_t id3_latin1_length(id3_latin1_t const *latin1)
{
id3_latin1_t const *ptr = latin1;
while (*ptr)
++ptr;
return ptr - latin1;
}
/*
* NAME: latin1->size()
* DESCRIPTION: return the encoding size of a latin1 string
*/
id3_length_t id3_latin1_size(id3_latin1_t const *latin1)
{
return id3_latin1_length(latin1) + 1;
}
/*
* NAME: latin1->copy()
* DESCRIPTION: copy a latin1 string
*/
void id3_latin1_copy(id3_latin1_t *dest, id3_latin1_t const *src)
{
while ((*dest++ = *src++))
;
}
/*
* NAME: latin1->duplicate()
* DESCRIPTION: duplicate a latin1 string
*/
id3_latin1_t *id3_latin1_duplicate(id3_latin1_t const *src)
{
id3_latin1_t *latin1;
latin1 = malloc(id3_latin1_size(src) * sizeof(*latin1));
if (latin1)
id3_latin1_copy(latin1, src);
return latin1;
}
/*
* NAME: latin1->ucs4duplicate()
* DESCRIPTION: duplicate and decode a latin1 string into ucs4
*/
id3_ucs4_t *id3_latin1_ucs4duplicate(id3_latin1_t const *latin1)
{
id3_ucs4_t *ucs4;
ucs4 = malloc((id3_latin1_length(latin1) + 1) * sizeof(*ucs4));
if (ucs4)
id3_latin1_decode(latin1, ucs4);
return release(ucs4);
}
/*
* NAME: latin1->decodechar()
* DESCRIPTION: decode a (single) latin1 char into a single ucs4 char
*/
id3_length_t id3_latin1_decodechar(id3_latin1_t const *latin1,
id3_ucs4_t *ucs4)
{
*ucs4 = *latin1;
return 1;
}
/*
* NAME: latin1->encodechar()
* DESCRIPTION: encode a single ucs4 char into a (single) latin1 char
*/
id3_length_t id3_latin1_encodechar(id3_latin1_t *latin1, id3_ucs4_t ucs4)
{
*latin1 = ucs4;
if (ucs4 > 0x000000ffL)
*latin1 = ID3_UCS4_REPLACEMENTCHAR;
return 1;
}
/*
* NAME: latin1->decode()
* DESCRIPTION: decode a complete latin1 string into a ucs4 string
*/
void id3_latin1_decode(id3_latin1_t const *latin1, id3_ucs4_t *ucs4)
{
do
latin1 += id3_latin1_decodechar(latin1, ucs4);
while (*ucs4++);
}
/*
* NAME: latin1->encode()
* DESCRIPTION: encode a complete ucs4 string into a latin1 string
*/
void id3_latin1_encode(id3_latin1_t *latin1, id3_ucs4_t const *ucs4)
{
do
latin1 += id3_latin1_encodechar(latin1, *ucs4);
while (*ucs4++);
}
/*
* NAME: latin1->put()
* DESCRIPTION: serialize a single latin1 character
*/
id3_length_t id3_latin1_put(id3_byte_t **ptr, id3_latin1_t latin1)
{
if (ptr)
*(*ptr)++ = latin1;
return 1;
}
/*
* NAME: latin1->get()
* DESCRIPTION: deserialize a single latin1 character
*/
id3_latin1_t id3_latin1_get(id3_byte_t const **ptr)
{
return *(*ptr)++;
}
/*
* NAME: latin1->serialize()
* DESCRIPTION: serialize a ucs4 string using latin1 encoding
*/
id3_length_t id3_latin1_serialize(id3_byte_t **ptr, id3_ucs4_t const *ucs4,
int terminate)
{
id3_length_t size = 0;
id3_latin1_t latin1[1], *out;
while (*ucs4) {
switch (id3_latin1_encodechar(out = latin1, *ucs4++)) {
case 1: size += id3_latin1_put(ptr, *out++);
case 0: break;
}
}
if (terminate)
size += id3_latin1_put(ptr, 0);
return size;
}
/*
* NAME: latin1->deserialize()
* DESCRIPTION: deserialize a ucs4 string using latin1 encoding
*/
id3_ucs4_t *id3_latin1_deserialize(id3_byte_t const **ptr, id3_length_t length)
{
id3_byte_t const *end;
id3_latin1_t *latin1ptr, *latin1;
id3_ucs4_t *ucs4;
end = *ptr + length;
latin1 = malloc((length + 1) * sizeof(*latin1));
if (latin1 == 0)
return 0;
latin1ptr = latin1;
while (end - *ptr > 0 && (*latin1ptr = id3_latin1_get(ptr)))
++latin1ptr;
*latin1ptr = 0;
ucs4 = malloc((id3_latin1_length(latin1) + 1) * sizeof(*ucs4));
if (ucs4)
id3_latin1_decode(latin1, ucs4);
free(latin1);
return ucs4;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: latin1.h,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_LATIN1_H
# define LIBID3TAG_LATIN1_H
# include "id3tag.h"
id3_length_t id3_latin1_length(id3_latin1_t const *);
id3_length_t id3_latin1_size(id3_latin1_t const *);
void id3_latin1_copy(id3_latin1_t *, id3_latin1_t const *);
id3_latin1_t *id3_latin1_duplicate(id3_latin1_t const *);
id3_length_t id3_latin1_decodechar(id3_latin1_t const *, id3_ucs4_t *);
id3_length_t id3_latin1_encodechar(id3_latin1_t *, id3_ucs4_t);
void id3_latin1_decode(id3_latin1_t const *, id3_ucs4_t *);
void id3_latin1_encode(id3_latin1_t *, id3_ucs4_t const *);
id3_length_t id3_latin1_put(id3_byte_t **, id3_latin1_t);
id3_latin1_t id3_latin1_get(id3_byte_t const **);
id3_length_t id3_latin1_serialize(id3_byte_t **, id3_ucs4_t const *, int);
id3_ucs4_t *id3_latin1_deserialize(id3_byte_t const **, id3_length_t);
# endif
# @configure_input@
# Directories...
$prefix=@prefix@
$exec_prefix=@exec_prefix@
$srcdir=@srcdir@
# Product information
%product @PACKAGE@
%copyright GPL
%vendor Underbit Technologies, Inc. <info@underbit.com>
%license @srcdir@/COPYING
%readme @srcdir@/README
%description libid3tag is an ID3 tag manipulation library.
%version @VERSION@
%packager Giuseppe "Cowo" Corbelli <cowo@lugbs.linux.it>
%system all
f 0755 root root @libdir@/libid3tag.la .libs/libid3tag.lai
f 0644 root root @libdir@/libid3tag.a .libs/libid3tag.a
f 0644 root root @includedir@/id3tag.h @srcdir@/id3tag.h
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: parse.c,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# ifdef HAVE_ASSERT_H
# include <assert.h>
# endif
# include <stdlib.h>
# include <string.h>
# include "id3tag.h"
# include "parse.h"
# include "latin1.h"
# include "utf16.h"
# include "utf8.h"
signed long id3_parse_int(id3_byte_t const **ptr, unsigned int bytes)
{
signed long value = 0;
assert(bytes >= 1 && bytes <= 4);
if (**ptr & 0x80)
value = ~0;
switch (bytes) {
case 4: value = (value << 8) | *(*ptr)++;
case 3: value = (value << 8) | *(*ptr)++;
case 2: value = (value << 8) | *(*ptr)++;
case 1: value = (value << 8) | *(*ptr)++;
}
return value;
}
unsigned long id3_parse_uint(id3_byte_t const **ptr, unsigned int bytes)
{
unsigned long value = 0;
assert(bytes >= 1 && bytes <= 4);
switch (bytes) {
case 4: value = (value << 8) | *(*ptr)++;
case 3: value = (value << 8) | *(*ptr)++;
case 2: value = (value << 8) | *(*ptr)++;
case 1: value = (value << 8) | *(*ptr)++;
}
return value;
}
unsigned long id3_parse_syncsafe(id3_byte_t const **ptr, unsigned int bytes)
{
unsigned long value = 0;
assert(bytes == 4 || bytes == 5);
switch (bytes) {
case 5: value = (value << 4) | (*(*ptr)++ & 0x0f);
case 4: value = (value << 7) | (*(*ptr)++ & 0x7f);
value = (value << 7) | (*(*ptr)++ & 0x7f);
value = (value << 7) | (*(*ptr)++ & 0x7f);
value = (value << 7) | (*(*ptr)++ & 0x7f);
}
return value;
}
void id3_parse_immediate(id3_byte_t const **ptr, unsigned int bytes,
char *value)
{
assert(value);
assert(bytes == 8 || bytes == 4 || bytes == 3);
switch (bytes) {
case 8: *value++ = *(*ptr)++;
*value++ = *(*ptr)++;
*value++ = *(*ptr)++;
*value++ = *(*ptr)++;
case 4: *value++ = *(*ptr)++;
case 3: *value++ = *(*ptr)++;
*value++ = *(*ptr)++;
*value++ = *(*ptr)++;
}
*value = 0;
}
id3_latin1_t *id3_parse_latin1(id3_byte_t const **ptr, id3_length_t length,
int full)
{
id3_byte_t const *end;
int terminated = 0;
id3_latin1_t *latin1;
end = memchr(*ptr, 0, length);
if (end == 0)
end = *ptr + length;
else {
length = end - *ptr;
terminated = 1;
}
latin1 = malloc(length + 1);
if (latin1) {
memcpy(latin1, *ptr, length);
latin1[length] = 0;
if (!full) {
id3_latin1_t *check;
for (check = latin1; *check; ++check) {
if (*check == '\n')
*check = ' ';
}
}
}
*ptr += length + terminated;
return latin1;
}
id3_ucs4_t *id3_parse_string(id3_byte_t const **ptr, id3_length_t length,
enum id3_field_textencoding encoding, int full)
{
id3_ucs4_t *ucs4 = 0;
enum id3_utf16_byteorder byteorder = ID3_UTF16_BYTEORDER_ANY;
switch (encoding) {
case ID3_FIELD_TEXTENCODING_ISO_8859_1:
ucs4 = id3_latin1_deserialize(ptr, length);
break;
case ID3_FIELD_TEXTENCODING_UTF_16BE:
byteorder = ID3_UTF16_BYTEORDER_BE;
case ID3_FIELD_TEXTENCODING_UTF_16:
ucs4 = id3_utf16_deserialize(ptr, length, byteorder);
break;
case ID3_FIELD_TEXTENCODING_UTF_8:
ucs4 = id3_utf8_deserialize(ptr, length);
break;
}
if (ucs4 && !full) {
id3_ucs4_t *check;
for (check = ucs4; *check; ++check) {
if (*check == '\n')
*check = ' ';
}
}
return ucs4;
}
id3_byte_t *id3_parse_binary(id3_byte_t const **ptr, id3_length_t length)
{
id3_byte_t *data;
if (length == 0)
return malloc(1);
data = malloc(length);
if (data)
memcpy(data, *ptr, length);
*ptr += length;
return data;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: parse.h,v 1.6 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_PARSE_H
# define LIBID3TAG_PARSE_H
signed long id3_parse_int(id3_byte_t const **, unsigned int);
unsigned long id3_parse_uint(id3_byte_t const **, unsigned int);
unsigned long id3_parse_syncsafe(id3_byte_t const **, unsigned int);
void id3_parse_immediate(id3_byte_t const **, unsigned int, char *);
id3_latin1_t *id3_parse_latin1(id3_byte_t const **, id3_length_t, int);
id3_ucs4_t *id3_parse_string(id3_byte_t const **, id3_length_t,
enum id3_field_textencoding, int);
id3_byte_t *id3_parse_binary(id3_byte_t const **, id3_length_t);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: render.c,v 1.11 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <string.h>
# include <stdlib.h>
# ifdef HAVE_ASSERT_H
# include <assert.h>
# endif
# include "id3tag.h"
# include "render.h"
# include "ucs4.h"
# include "latin1.h"
# include "utf16.h"
# include "utf8.h"
id3_length_t id3_render_immediate(id3_byte_t **ptr,
char const *value, unsigned int bytes)
{
assert(value);
assert(bytes == 8 || bytes == 4 || bytes == 3);
if (ptr) {
switch (bytes) {
case 8: *(*ptr)++ = *value++;
*(*ptr)++ = *value++;
*(*ptr)++ = *value++;
*(*ptr)++ = *value++;
case 4: *(*ptr)++ = *value++;
case 3: *(*ptr)++ = *value++;
*(*ptr)++ = *value++;
*(*ptr)++ = *value++;
}
}
return bytes;
}
id3_length_t id3_render_syncsafe(id3_byte_t **ptr,
unsigned long num, unsigned int bytes)
{
assert(bytes == 4 || bytes == 5);
if (ptr) {
switch (bytes) {
case 5: *(*ptr)++ = (num >> 28) & 0x0f;
case 4: *(*ptr)++ = (num >> 21) & 0x7f;
*(*ptr)++ = (num >> 14) & 0x7f;
*(*ptr)++ = (num >> 7) & 0x7f;
*(*ptr)++ = (num >> 0) & 0x7f;
}
}
return bytes;
}
id3_length_t id3_render_int(id3_byte_t **ptr,
signed long num, unsigned int bytes)
{
assert(bytes >= 1 && bytes <= 4);
if (ptr) {
switch (bytes) {
case 4: *(*ptr)++ = num >> 24;
case 3: *(*ptr)++ = num >> 16;
case 2: *(*ptr)++ = num >> 8;
case 1: *(*ptr)++ = num >> 0;
}
}
return bytes;
}
id3_length_t id3_render_binary(id3_byte_t **ptr,
id3_byte_t const *data, id3_length_t length)
{
if (data == 0)
return 0;
if (ptr) {
memcpy(*ptr, data, length);
*ptr += length;
}
return length;
}
id3_length_t id3_render_latin1(id3_byte_t **ptr,
id3_latin1_t const *latin1, int terminate)
{
id3_length_t size;
if (latin1 == 0)
latin1 = "";
size = id3_latin1_size(latin1);
if (!terminate)
--size;
if (ptr) {
memcpy(*ptr, latin1, size);
*ptr += size;
}
return size;
}
id3_length_t id3_render_string(id3_byte_t **ptr, id3_ucs4_t const *ucs4,
enum id3_field_textencoding encoding,
int terminate)
{
enum id3_utf16_byteorder byteorder = ID3_UTF16_BYTEORDER_ANY;
if (ucs4 == 0)
ucs4 = id3_ucs4_empty;
switch (encoding) {
case ID3_FIELD_TEXTENCODING_ISO_8859_1:
return id3_latin1_serialize(ptr, ucs4, terminate);
case ID3_FIELD_TEXTENCODING_UTF_16BE:
byteorder = ID3_UTF16_BYTEORDER_BE;
case ID3_FIELD_TEXTENCODING_UTF_16:
return id3_utf16_serialize(ptr, ucs4, byteorder, terminate);
case ID3_FIELD_TEXTENCODING_UTF_8:
return id3_utf8_serialize(ptr, ucs4, terminate);
}
return 0;
}
id3_length_t id3_render_padding(id3_byte_t **ptr, id3_byte_t value,
id3_length_t length)
{
if (ptr) {
memset(*ptr, value, length);
*ptr += length;
}
return length;
}
/*
* NAME: render->paddedstring()
* DESCRIPTION: render a space-padded string using latin1 encoding
*/
id3_length_t id3_render_paddedstring(id3_byte_t **ptr, id3_ucs4_t const *ucs4,
id3_length_t length)
{
id3_ucs4_t padded[31], *data, *end;
/* latin1 encoding only (this is used for ID3v1 fields) */
assert(length <= 30);
data = padded;
end = data + length;
if (ucs4) {
while (*ucs4 && end - data > 0) {
*data++ = *ucs4++;
if (data[-1] == '\n')
data[-1] = ' ';
}
}
while (end - data > 0)
*data++ = ' ';
*data = 0;
return id3_latin1_serialize(ptr, padded, 0);
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: render.h,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_RENDER_H
# define LIBID3TAG_RENDER_H
# include "id3tag.h"
id3_length_t id3_render_immediate(id3_byte_t **, char const *, unsigned int);
id3_length_t id3_render_syncsafe(id3_byte_t **, unsigned long, unsigned int);
id3_length_t id3_render_int(id3_byte_t **, signed long, unsigned int);
id3_length_t id3_render_binary(id3_byte_t **,
id3_byte_t const *, id3_length_t);
id3_length_t id3_render_latin1(id3_byte_t **, id3_latin1_t const *, int);
id3_length_t id3_render_string(id3_byte_t **, id3_ucs4_t const *,
enum id3_field_textencoding, int);
id3_length_t id3_render_padding(id3_byte_t **, id3_byte_t, id3_length_t);
id3_length_t id3_render_paddedstring(id3_byte_t **, id3_ucs4_t const *,
id3_length_t);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: tag.h,v 1.10 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_TAG_H
# define LIBID3TAG_TAG_H
# include "id3tag.h"
void id3_tag_addref(struct id3_tag *);
void id3_tag_delref(struct id3_tag *);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: ucs4.c,v 1.13 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <stdlib.h>
# include "id3tag.h"
# include "ucs4.h"
# include "latin1.h"
# include "utf16.h"
# include "utf8.h"
id3_ucs4_t const id3_ucs4_empty[] = { 0 };
/*
* NAME: ucs4->length()
* DESCRIPTION: return the number of ucs4 chars represented by a ucs4 string
*/
id3_length_t id3_ucs4_length(id3_ucs4_t const *ucs4)
{
id3_ucs4_t const *ptr = ucs4;
while (*ptr)
++ptr;
return ptr - ucs4;
}
/*
* NAME: ucs4->size()
* DESCRIPTION: return the encoding size of a ucs4 string
*/
id3_length_t id3_ucs4_size(id3_ucs4_t const *ucs4)
{
return id3_ucs4_length(ucs4) + 1;
}
/*
* NAME: ucs4->latin1size()
* DESCRIPTION: return the encoding size of a latin1-encoded ucs4 string
*/
id3_length_t id3_ucs4_latin1size(id3_ucs4_t const *ucs4)
{
return id3_ucs4_size(ucs4);
}
/*
* NAME: ucs4->utf16size()
* DESCRIPTION: return the encoding size of a utf16-encoded ucs4 string
*/
id3_length_t id3_ucs4_utf16size(id3_ucs4_t const *ucs4)
{
id3_length_t size = 0;
while (*ucs4) {
++size;
if (*ucs4 >= 0x00010000L &&
*ucs4 <= 0x0010ffffL)
++size;
++ucs4;
}
return size + 1;
}
/*
* NAME: ucs4->utf8size()
* DESCRIPTION: return the encoding size of a utf8-encoded ucs4 string
*/
id3_length_t id3_ucs4_utf8size(id3_ucs4_t const *ucs4)
{
id3_length_t size = 0;
while (*ucs4) {
if (*ucs4 <= 0x0000007fL)
size += 1;
else if (*ucs4 <= 0x000007ffL)
size += 2;
else if (*ucs4 <= 0x0000ffffL)
size += 3;
else if (*ucs4 <= 0x001fffffL)
size += 4;
else if (*ucs4 <= 0x03ffffffL)
size += 5;
else if (*ucs4 <= 0x7fffffffL)
size += 6;
else
size += 2; /* based on U+00B7 replacement char */
++ucs4;
}
return size + 1;
}
/*
* NAME: ucs4->latin1duplicate()
* DESCRIPTION: duplicate and encode a ucs4 string into latin1
*/
id3_latin1_t *id3_ucs4_latin1duplicate(id3_ucs4_t const *ucs4)
{
id3_latin1_t *latin1;
latin1 = malloc(id3_ucs4_latin1size(ucs4) * sizeof(*latin1));
if (latin1)
id3_latin1_encode(latin1, ucs4);
return release(latin1);
}
/*
* NAME: ucs4->utf16duplicate()
* DESCRIPTION: duplicate and encode a ucs4 string into utf16
*/
id3_utf16_t *id3_ucs4_utf16duplicate(id3_ucs4_t const *ucs4)
{
id3_utf16_t *utf16;
utf16 = malloc(id3_ucs4_utf16size(ucs4) * sizeof(*utf16));
if (utf16)
id3_utf16_encode(utf16, ucs4);
return release(utf16);
}
/*
* NAME: ucs4->utf8duplicate()
* DESCRIPTION: duplicate and encode a ucs4 string into utf8
*/
id3_utf8_t *id3_ucs4_utf8duplicate(id3_ucs4_t const *ucs4)
{
id3_utf8_t *utf8;
utf8 = malloc(id3_ucs4_utf8size(ucs4) * sizeof(*utf8));
if (utf8)
id3_utf8_encode(utf8, ucs4);
return release(utf8);
}
/*
* NAME: ucs4->copy()
* DESCRIPTION: copy a ucs4 string
*/
void id3_ucs4_copy(id3_ucs4_t *dest, id3_ucs4_t const *src)
{
while ((*dest++ = *src++))
;
}
/*
* NAME: ucs4->duplicate()
* DESCRIPTION: duplicate a ucs4 string
*/
id3_ucs4_t *id3_ucs4_duplicate(id3_ucs4_t const *src)
{
id3_ucs4_t *ucs4;
ucs4 = malloc(id3_ucs4_size(src) * sizeof(*ucs4));
if (ucs4)
id3_ucs4_copy(ucs4, src);
return ucs4;
}
/*
* NAME: ucs4->putnumber()
* DESCRIPTION: write a ucs4 string containing a (positive) decimal number
*/
void id3_ucs4_putnumber(id3_ucs4_t *ucs4, unsigned long number)
{
int digits[10], *digit;
digit = digits;
do {
*digit++ = number % 10;
number /= 10;
}
while (number);
while (digit != digits)
*ucs4++ = '0' + *--digit;
*ucs4 = 0;
}
/*
* NAME: ucs4->getnumber()
* DESCRIPTION: read a ucs4 string containing a (positive) decimal number
*/
unsigned long id3_ucs4_getnumber(id3_ucs4_t const *ucs4)
{
unsigned long number = 0;
while (*ucs4 >= '0' && *ucs4 <= '9')
number = 10 * number + (*ucs4++ - '0');
return number;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: ucs4.h,v 1.11 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_UCS4_H
# define LIBID3TAG_UCS4_H
# include "id3tag.h"
# define ID3_UCS4_REPLACEMENTCHAR 0x000000b7L /* middle dot */
extern id3_ucs4_t const id3_ucs4_empty[];
id3_length_t id3_ucs4_length(id3_ucs4_t const *);
id3_length_t id3_ucs4_size(id3_ucs4_t const *);
id3_length_t id3_ucs4_latin1size(id3_ucs4_t const *);
id3_length_t id3_ucs4_utf16size(id3_ucs4_t const *);
id3_length_t id3_ucs4_utf8size(id3_ucs4_t const *);
void id3_ucs4_copy(id3_ucs4_t *, id3_ucs4_t const *);
id3_ucs4_t *id3_ucs4_duplicate(id3_ucs4_t const *);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: utf16.c,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <stdlib.h>
# include "id3tag.h"
# include "utf16.h"
# include "ucs4.h"
/*
* NAME: utf16->length()
* DESCRIPTION: return the number of ucs4 chars represented by a utf16 string
*/
id3_length_t id3_utf16_length(id3_utf16_t const *utf16)
{
id3_length_t length = 0;
while (*utf16) {
if (utf16[0] < 0xd800 || utf16[0] > 0xdfff)
++length;
else if (utf16[0] >= 0xd800 && utf16[0] <= 0xdbff &&
utf16[1] >= 0xdc00 && utf16[1] <= 0xdfff) {
++length;
++utf16;
}
++utf16;
}
return length;
}
/*
* NAME: utf16->size()
* DESCRIPTION: return the encoding size of a utf16 string
*/
id3_length_t id3_utf16_size(id3_utf16_t const *utf16)
{
id3_utf16_t const *ptr = utf16;
while (*ptr)
++ptr;
return ptr - utf16 + 1;
}
/*
* NAME: utf16->ucs4duplicate()
* DESCRIPTION: duplicate and decode a utf16 string into ucs4
*/
id3_ucs4_t *id3_utf16_ucs4duplicate(id3_utf16_t const *utf16)
{
id3_ucs4_t *ucs4;
ucs4 = malloc((id3_utf16_length(utf16) + 1) * sizeof(*ucs4));
if (ucs4)
id3_utf16_decode(utf16, ucs4);
return release(ucs4);
}
/*
* NAME: utf16->decodechar()
* DESCRIPTION: decode a series of utf16 chars into a single ucs4 char
*/
id3_length_t id3_utf16_decodechar(id3_utf16_t const *utf16, id3_ucs4_t *ucs4)
{
id3_utf16_t const *start = utf16;
while (1) {
if (utf16[0] < 0xd800 || utf16[0] > 0xdfff) {
*ucs4 = utf16[0];
return utf16 - start + 1;
}
else if (utf16[0] >= 0xd800 && utf16[0] <= 0xdbff &&
utf16[1] >= 0xdc00 && utf16[1] <= 0xdfff) {
*ucs4 = (((utf16[0] & 0x03ffL) << 10) |
((utf16[1] & 0x03ffL) << 0)) + 0x00010000L;
return utf16 - start + 2;
}
++utf16;
}
}
/*
* NAME: utf16->encodechar()
* DESCRIPTION: encode a single ucs4 char into a series of up to 2 utf16 chars
*/
id3_length_t id3_utf16_encodechar(id3_utf16_t *utf16, id3_ucs4_t ucs4)
{
if (ucs4 < 0x00010000L) {
utf16[0] = ucs4;
return 1;
}
else if (ucs4 < 0x00110000L) {
ucs4 -= 0x00010000L;
utf16[0] = ((ucs4 >> 10) & 0x3ff) | 0xd800;
utf16[1] = ((ucs4 >> 0) & 0x3ff) | 0xdc00;
return 2;
}
/* default */
return id3_utf16_encodechar(utf16, ID3_UCS4_REPLACEMENTCHAR);
}
/*
* NAME: utf16->decode()
* DESCRIPTION: decode a complete utf16 string into a ucs4 string
*/
void id3_utf16_decode(id3_utf16_t const *utf16, id3_ucs4_t *ucs4)
{
do
utf16 += id3_utf16_decodechar(utf16, ucs4);
while (*ucs4++);
}
/*
* NAME: utf16->encode()
* DESCRIPTION: encode a complete ucs4 string into a utf16 string
*/
void id3_utf16_encode(id3_utf16_t *utf16, id3_ucs4_t const *ucs4)
{
do
utf16 += id3_utf16_encodechar(utf16, *ucs4);
while (*ucs4++);
}
/*
* NAME: utf16->put()
* DESCRIPTION: serialize a single utf16 character
*/
id3_length_t id3_utf16_put(id3_byte_t **ptr, id3_utf16_t utf16,
enum id3_utf16_byteorder byteorder)
{
if (ptr) {
switch (byteorder) {
default:
case ID3_UTF16_BYTEORDER_BE:
(*ptr)[0] = (utf16 >> 8) & 0xff;
(*ptr)[1] = (utf16 >> 0) & 0xff;
break;
case ID3_UTF16_BYTEORDER_LE:
(*ptr)[0] = (utf16 >> 0) & 0xff;
(*ptr)[1] = (utf16 >> 8) & 0xff;
break;
}
*ptr += 2;
}
return 2;
}
/*
* NAME: utf16->get()
* DESCRIPTION: deserialize a single utf16 character
*/
id3_utf16_t id3_utf16_get(id3_byte_t const **ptr,
enum id3_utf16_byteorder byteorder)
{
id3_utf16_t utf16;
switch (byteorder) {
default:
case ID3_UTF16_BYTEORDER_BE:
utf16 =
((*ptr)[0] << 8) |
((*ptr)[1] << 0);
break;
case ID3_UTF16_BYTEORDER_LE:
utf16 =
((*ptr)[0] << 0) |
((*ptr)[1] << 8);
break;
}
*ptr += 2;
return utf16;
}
/*
* NAME: utf16->serialize()
* DESCRIPTION: serialize a ucs4 string using utf16 encoding
*/
id3_length_t id3_utf16_serialize(id3_byte_t **ptr, id3_ucs4_t const *ucs4,
enum id3_utf16_byteorder byteorder,
int terminate)
{
id3_length_t size = 0;
id3_utf16_t utf16[2], *out;
if (byteorder == ID3_UTF16_BYTEORDER_ANY)
size += id3_utf16_put(ptr, 0xfeff, byteorder);
while (*ucs4) {
switch (id3_utf16_encodechar(out = utf16, *ucs4++)) {
case 2: size += id3_utf16_put(ptr, *out++, byteorder);
case 1: size += id3_utf16_put(ptr, *out++, byteorder);
case 0: break;
}
}
if (terminate)
size += id3_utf16_put(ptr, 0, byteorder);
return size;
}
/*
* NAME: utf16->deserialize()
* DESCRIPTION: deserialize a ucs4 string using utf16 encoding
*/
id3_ucs4_t *id3_utf16_deserialize(id3_byte_t const **ptr, id3_length_t length,
enum id3_utf16_byteorder byteorder)
{
id3_byte_t const *end;
id3_utf16_t *utf16ptr, *utf16;
id3_ucs4_t *ucs4;
end = *ptr + (length & ~1);
utf16 = malloc((length / 2 + 1) * sizeof(*utf16));
if (utf16 == 0)
return 0;
if (byteorder == ID3_UTF16_BYTEORDER_ANY && end - *ptr > 0) {
switch (((*ptr)[0] << 8) |
((*ptr)[1] << 0)) {
case 0xfeff:
byteorder = ID3_UTF16_BYTEORDER_BE;
*ptr += 2;
break;
case 0xfffe:
byteorder = ID3_UTF16_BYTEORDER_LE;
*ptr += 2;
break;
}
}
utf16ptr = utf16;
while (end - *ptr > 0 && (*utf16ptr = id3_utf16_get(ptr, byteorder)))
++utf16ptr;
*utf16ptr = 0;
ucs4 = malloc((id3_utf16_length(utf16) + 1) * sizeof(*ucs4));
if (ucs4)
id3_utf16_decode(utf16, ucs4);
free(utf16);
return ucs4;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: utf16.h,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_UTF16_H
# define LIBID3TAG_UTF16_H
# include "id3tag.h"
enum id3_utf16_byteorder {
ID3_UTF16_BYTEORDER_ANY,
ID3_UTF16_BYTEORDER_BE,
ID3_UTF16_BYTEORDER_LE
};
id3_length_t id3_utf16_length(id3_utf16_t const *);
id3_length_t id3_utf16_size(id3_utf16_t const *);
id3_length_t id3_utf16_decodechar(id3_utf16_t const *, id3_ucs4_t *);
id3_length_t id3_utf16_encodechar(id3_utf16_t *, id3_ucs4_t);
void id3_utf16_decode(id3_utf16_t const *, id3_ucs4_t *);
void id3_utf16_encode(id3_utf16_t *, id3_ucs4_t const *);
id3_length_t id3_utf16_put(id3_byte_t **, id3_utf16_t,
enum id3_utf16_byteorder);
id3_utf16_t id3_utf16_get(id3_byte_t const **, enum id3_utf16_byteorder);
id3_length_t id3_utf16_serialize(id3_byte_t **, id3_ucs4_t const *,
enum id3_utf16_byteorder, int);
id3_ucs4_t *id3_utf16_deserialize(id3_byte_t const **, id3_length_t,
enum id3_utf16_byteorder);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: utf8.c,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <stdlib.h>
# include "id3tag.h"
# include "utf8.h"
# include "ucs4.h"
/*
* NAME: utf8->length()
* DESCRIPTION: return the number of ucs4 chars represented by a utf8 string
*/
id3_length_t id3_utf8_length(id3_utf8_t const *utf8)
{
id3_length_t length = 0;
while (*utf8) {
if ((utf8[0] & 0x80) == 0x00)
++length;
else if ((utf8[0] & 0xe0) == 0xc0 &&
(utf8[1] & 0xc0) == 0x80) {
if (((utf8[0] & 0x1fL) << 6) >= 0x00000080L) {
++length;
utf8 += 1;
}
}
else if ((utf8[0] & 0xf0) == 0xe0 &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80) {
if ((((utf8[0] & 0x0fL) << 12) |
((utf8[1] & 0x3fL) << 6)) >= 0x00000800L) {
++length;
utf8 += 2;
}
}
else if ((utf8[0] & 0xf8) == 0xf0 &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80 &&
(utf8[3] & 0xc0) == 0x80) {
if ((((utf8[0] & 0x07L) << 18) |
((utf8[1] & 0x3fL) << 12)) >= 0x00010000L) {
++length;
utf8 += 3;
}
}
else if ((utf8[0] & 0xfc) == 0xf8 &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80 &&
(utf8[3] & 0xc0) == 0x80 &&
(utf8[4] & 0xc0) == 0x80) {
if ((((utf8[0] & 0x03L) << 24) |
((utf8[0] & 0x3fL) << 18)) >= 0x00200000L) {
++length;
utf8 += 4;
}
}
else if ((utf8[0] & 0xfe) == 0xfc &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80 &&
(utf8[3] & 0xc0) == 0x80 &&
(utf8[4] & 0xc0) == 0x80 &&
(utf8[5] & 0xc0) == 0x80) {
if ((((utf8[0] & 0x01L) << 30) |
((utf8[0] & 0x3fL) << 24)) >= 0x04000000L) {
++length;
utf8 += 5;
}
}
++utf8;
}
return length;
}
/*
* NAME: utf8->size()
* DESCRIPTION: return the encoding size of a utf8 string
*/
id3_length_t id3_utf8_size(id3_utf8_t const *utf8)
{
id3_utf8_t const *ptr = utf8;
while (*ptr)
++ptr;
return ptr - utf8 + 1;
}
/*
* NAME: utf8->ucs4duplicate()
* DESCRIPTION: duplicate and decode a utf8 string into ucs4
*/
id3_ucs4_t *id3_utf8_ucs4duplicate(id3_utf8_t const *utf8)
{
id3_ucs4_t *ucs4;
ucs4 = malloc((id3_utf8_length(utf8) + 1) * sizeof(*ucs4));
if (ucs4)
id3_utf8_decode(utf8, ucs4);
return release(ucs4);
}
/*
* NAME: utf8->decodechar()
* DESCRIPTION: decode a series of utf8 chars into a single ucs4 char
*/
id3_length_t id3_utf8_decodechar(id3_utf8_t const *utf8, id3_ucs4_t *ucs4)
{
id3_utf8_t const *start = utf8;
while (1) {
if ((utf8[0] & 0x80) == 0x00) {
*ucs4 = utf8[0];
return utf8 - start + 1;
}
else if ((utf8[0] & 0xe0) == 0xc0 &&
(utf8[1] & 0xc0) == 0x80) {
*ucs4 =
((utf8[0] & 0x1fL) << 6) |
((utf8[1] & 0x3fL) << 0);
if (*ucs4 >= 0x00000080L)
return utf8 - start + 2;
}
else if ((utf8[0] & 0xf0) == 0xe0 &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80) {
*ucs4 =
((utf8[0] & 0x0fL) << 12) |
((utf8[1] & 0x3fL) << 6) |
((utf8[2] & 0x3fL) << 0);
if (*ucs4 >= 0x00000800L)
return utf8 - start + 3;
}
else if ((utf8[0] & 0xf8) == 0xf0 &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80 &&
(utf8[3] & 0xc0) == 0x80) {
*ucs4 =
((utf8[0] & 0x07L) << 18) |
((utf8[1] & 0x3fL) << 12) |
((utf8[2] & 0x3fL) << 6) |
((utf8[3] & 0x3fL) << 0);
if (*ucs4 >= 0x00010000L)
return utf8 - start + 4;
}
else if ((utf8[0] & 0xfc) == 0xf8 &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80 &&
(utf8[3] & 0xc0) == 0x80 &&
(utf8[4] & 0xc0) == 0x80) {
*ucs4 =
((utf8[0] & 0x03L) << 24) |
((utf8[1] & 0x3fL) << 18) |
((utf8[2] & 0x3fL) << 12) |
((utf8[3] & 0x3fL) << 6) |
((utf8[4] & 0x3fL) << 0);
if (*ucs4 >= 0x00200000L)
return utf8 - start + 5;
}
else if ((utf8[0] & 0xfe) == 0xfc &&
(utf8[1] & 0xc0) == 0x80 &&
(utf8[2] & 0xc0) == 0x80 &&
(utf8[3] & 0xc0) == 0x80 &&
(utf8[4] & 0xc0) == 0x80 &&
(utf8[5] & 0xc0) == 0x80) {
*ucs4 =
((utf8[0] & 0x01L) << 30) |
((utf8[1] & 0x3fL) << 24) |
((utf8[2] & 0x3fL) << 18) |
((utf8[3] & 0x3fL) << 12) |
((utf8[4] & 0x3fL) << 6) |
((utf8[5] & 0x3fL) << 0);
if (*ucs4 >= 0x04000000L)
return utf8 - start + 6;
}
++utf8;
}
}
/*
* NAME: utf8->encodechar()
* DESCRIPTION: encode a single ucs4 char into a series of up to 6 utf8 chars
*/
id3_length_t id3_utf8_encodechar(id3_utf8_t *utf8, id3_ucs4_t ucs4)
{
if (ucs4 <= 0x0000007fL) {
utf8[0] = ucs4;
return 1;
}
else if (ucs4 <= 0x000007ffL) {
utf8[0] = 0xc0 | ((ucs4 >> 6) & 0x1f);
utf8[1] = 0x80 | ((ucs4 >> 0) & 0x3f);
return 2;
}
else if (ucs4 <= 0x0000ffffL) {
utf8[0] = 0xe0 | ((ucs4 >> 12) & 0x0f);
utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f);
utf8[2] = 0x80 | ((ucs4 >> 0) & 0x3f);
return 3;
}
else if (ucs4 <= 0x001fffffL) {
utf8[0] = 0xf0 | ((ucs4 >> 18) & 0x07);
utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f);
utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f);
utf8[3] = 0x80 | ((ucs4 >> 0) & 0x3f);
return 4;
}
else if (ucs4 <= 0x03ffffffL) {
utf8[0] = 0xf8 | ((ucs4 >> 24) & 0x03);
utf8[1] = 0x80 | ((ucs4 >> 18) & 0x3f);
utf8[2] = 0x80 | ((ucs4 >> 12) & 0x3f);
utf8[3] = 0x80 | ((ucs4 >> 6) & 0x3f);
utf8[4] = 0x80 | ((ucs4 >> 0) & 0x3f);
return 5;
}
else if (ucs4 <= 0x7fffffffL) {
utf8[0] = 0xfc | ((ucs4 >> 30) & 0x01);
utf8[1] = 0x80 | ((ucs4 >> 24) & 0x3f);
utf8[2] = 0x80 | ((ucs4 >> 18) & 0x3f);
utf8[3] = 0x80 | ((ucs4 >> 12) & 0x3f);
utf8[4] = 0x80 | ((ucs4 >> 6) & 0x3f);
utf8[5] = 0x80 | ((ucs4 >> 0) & 0x3f);
return 6;
}
/* default */
return id3_utf8_encodechar(utf8, ID3_UCS4_REPLACEMENTCHAR);
}
/*
* NAME: utf8->decode()
* DESCRIPTION: decode a complete utf8 string into a ucs4 string
*/
void id3_utf8_decode(id3_utf8_t const *utf8, id3_ucs4_t *ucs4)
{
do
utf8 += id3_utf8_decodechar(utf8, ucs4);
while (*ucs4++);
}
/*
* NAME: utf8->encode()
* DESCRIPTION: encode a complete ucs4 string into a utf8 string
*/
void id3_utf8_encode(id3_utf8_t *utf8, id3_ucs4_t const *ucs4)
{
do
utf8 += id3_utf8_encodechar(utf8, *ucs4);
while (*ucs4++);
}
/*
* NAME: utf8->put()
* DESCRIPTION: serialize a single utf8 character
*/
id3_length_t id3_utf8_put(id3_byte_t **ptr, id3_utf8_t utf8)
{
if (ptr)
*(*ptr)++ = utf8;
return 1;
}
/*
* NAME: utf8->get()
* DESCRIPTION: deserialize a single utf8 character
*/
id3_utf8_t id3_utf8_get(id3_byte_t const **ptr)
{
return *(*ptr)++;
}
/*
* NAME: utf8->serialize()
* DESCRIPTION: serialize a ucs4 string using utf8 encoding
*/
id3_length_t id3_utf8_serialize(id3_byte_t **ptr, id3_ucs4_t const *ucs4,
int terminate)
{
id3_length_t size = 0;
id3_utf8_t utf8[6], *out;
while (*ucs4) {
switch (id3_utf8_encodechar(out = utf8, *ucs4++)) {
case 6: size += id3_utf8_put(ptr, *out++);
case 5: size += id3_utf8_put(ptr, *out++);
case 4: size += id3_utf8_put(ptr, *out++);
case 3: size += id3_utf8_put(ptr, *out++);
case 2: size += id3_utf8_put(ptr, *out++);
case 1: size += id3_utf8_put(ptr, *out++);
case 0: break;
}
}
if (terminate)
size += id3_utf8_put(ptr, 0);
return size;
}
/*
* NAME: utf8->deserialize()
* DESCRIPTION: deserialize a ucs4 string using utf8 encoding
*/
id3_ucs4_t *id3_utf8_deserialize(id3_byte_t const **ptr, id3_length_t length)
{
id3_byte_t const *end;
id3_utf8_t *utf8ptr, *utf8;
id3_ucs4_t *ucs4;
end = *ptr + length;
utf8 = malloc((length + 1) * sizeof(*utf8));
if (utf8 == 0)
return 0;
utf8ptr = utf8;
while (end - *ptr > 0 && (*utf8ptr = id3_utf8_get(ptr)))
++utf8ptr;
*utf8ptr = 0;
ucs4 = malloc((id3_utf8_length(utf8) + 1) * sizeof(*ucs4));
if (ucs4)
id3_utf8_decode(utf8, ucs4);
free(utf8);
return ucs4;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: utf8.h,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_UTF8_H
# define LIBID3TAG_UTF8_H
# include "id3tag.h"
id3_length_t id3_utf8_length(id3_utf8_t const *);
id3_length_t id3_utf8_size(id3_utf8_t const *);
id3_length_t id3_utf8_decodechar(id3_utf8_t const *, id3_ucs4_t *);
id3_length_t id3_utf8_encodechar(id3_utf8_t *, id3_ucs4_t);
void id3_utf8_decode(id3_utf8_t const *, id3_ucs4_t *);
void id3_utf8_encode(id3_utf8_t *, id3_ucs4_t const *);
id3_length_t id3_utf8_put(id3_byte_t **, id3_utf8_t);
id3_utf8_t id3_utf8_get(id3_byte_t const **);
id3_length_t id3_utf8_serialize(id3_byte_t **, id3_ucs4_t const *, int);
id3_ucs4_t *id3_utf8_deserialize(id3_byte_t const **, id3_length_t);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: util.c,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include <stdlib.h>
# include <zlib.h>
# include "id3tag.h"
# include "util.h"
/*
* NAME: util->unsynchronise()
* DESCRIPTION: perform (in-place) unsynchronisation
*/
id3_length_t id3_util_unsynchronise(id3_byte_t *data, id3_length_t length)
{
id3_length_t bytes = 0, count;
id3_byte_t *end = data + length;
id3_byte_t const *ptr;
if (length == 0)
return 0;
for (ptr = data; ptr < end - 1; ++ptr) {
if (ptr[0] == 0xff && (ptr[1] == 0x00 || (ptr[1] & 0xe0) == 0xe0))
++bytes;
}
if (bytes) {
ptr = end;
end += bytes;
*--end = *--ptr;
for (count = bytes; count; *--end = *--ptr) {
if (ptr[-1] == 0xff && (ptr[0] == 0x00 || (ptr[0] & 0xe0) == 0xe0)) {
*--end = 0x00;
--count;
}
}
}
return length + bytes;
}
/*
* NAME: util->deunsynchronise()
* DESCRIPTION: undo unsynchronisation (in-place)
*/
id3_length_t id3_util_deunsynchronise(id3_byte_t *data, id3_length_t length)
{
id3_byte_t const *old, *end = data + length;
id3_byte_t *new;
if (length == 0)
return 0;
for (old = new = data; old < end - 1; ++old) {
*new++ = *old;
if (old[0] == 0xff && old[1] == 0x00)
++old;
}
*new++ = *old;
return new - data;
}
/*
* NAME: util->compress()
* DESCRIPTION: perform zlib deflate method compression
*/
id3_byte_t *id3_util_compress(id3_byte_t const *data, id3_length_t length,
id3_length_t *newlength)
{
id3_byte_t *compressed;
*newlength = length + 12;
*newlength += *newlength / 1000;
compressed = malloc(*newlength);
if (compressed) {
if (compress2(compressed, newlength, data, length,
Z_BEST_COMPRESSION) != Z_OK ||
*newlength >= length) {
free(compressed);
compressed = 0;
}
else {
id3_byte_t *resized;
resized = realloc(compressed, *newlength ? *newlength : 1);
if (resized)
compressed = resized;
}
}
return compressed;
}
/*
* NAME: util->decompress()
* DESCRIPTION: undo zlib deflate method compression
*/
id3_byte_t *id3_util_decompress(id3_byte_t const *data, id3_length_t length,
id3_length_t newlength)
{
id3_byte_t *decompressed;
decompressed = malloc(newlength ? newlength : 1);
if (decompressed) {
id3_length_t size;
size = newlength;
if (uncompress(decompressed, &size, data, length) != Z_OK ||
size != newlength) {
free(decompressed);
decompressed = 0;
}
}
return decompressed;
}
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: util.h,v 1.6 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_UTIL_H
# define LIBID3TAG_UTIL_H
# include "id3tag.h"
id3_length_t id3_util_unsynchronise(id3_byte_t *, id3_length_t);
id3_length_t id3_util_deunsynchronise(id3_byte_t *, id3_length_t);
id3_byte_t *id3_util_compress(id3_byte_t const *, id3_length_t,
id3_length_t *);
id3_byte_t *id3_util_decompress(id3_byte_t const *, id3_length_t,
id3_length_t);
# endif
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: version.c,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "global.h"
# include "id3tag.h"
# include "version.h"
char const id3_version[] = "ID3 Tag Library " ID3_VERSION;
char const id3_copyright[] = "Copyright (C) " ID3_PUBLISHYEAR " " ID3_AUTHOR;
char const id3_author[] = ID3_AUTHOR " <" ID3_EMAIL ">";
char const id3_build[] = ""
# if defined(DEBUG)
"DEBUG "
# elif defined(NDEBUG)
"NDEBUG "
# endif
# if defined(EXPERIMENTAL)
"EXPERIMENTAL "
# endif
;
/*
* libid3tag - ID3 tag manipulation library
* Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
*
* $Id: version.h,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBID3TAG_VERSION_H
# define LIBID3TAG_VERSION_H
# endif
libmad - MPEG audio decoder library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
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
If you would like to negotiate alternate licensing terms, you may do
so by contacting: Underbit Technologies, Inc. <info@underbit.com>
libmad - MPEG audio decoder library
Copyright (C) 2000-2004 Underbit Technologies, Inc.
$Id: CREDITS,v 1.5 2004/02/17 02:02:03 rob Exp $
===============================================================================
AUTHOR
Except where otherwise noted, all code was authored by:
Robert Leslie <rob@underbit.com>
CONTRIBUTORS
Significant contributions have been incorporated with thanks to:
Anonymous
2002/03/15: frame.c
- Reported problem with use of reserved emphasis value.
2003/08/31: layer12.c
- Suggested support for certain disallowed bitrate/mode
combinations.
Niek Albers <info@daansystems.com>
2003/04/21: layer3.c
- Reported runtime uninitialized use of `ptr' in designating
ancillary bits after a decoding error.
Christian Biere <cbiere@users.sourceforge.net>
2003/02/01: frame.c
- Reported assertion failure in layer3.c due to an
invalid/unsupported Layer III free format bitrate.
David Blythe <blythe@routefree.com>
2001/01/30: fixed.h
- Provided initial PowerPC fixed-point assembly.
Simon Burge <simonb@wasabisystems.com>
2000/09/20: imdct_l_arm.S
- Suggested patch for a.out compatibility.
Brian Cameron <Brian.Cameron@sun.com>
2003/07/02: huffman.c
- Suggested changes for improved portability.
Joshua Haberman <joshua@haberman.com>
2001/08/10: decoder.c, huffman.c
- Suggested portability fixes.
Timothy King <lordzork@lordzork.com>
2002/05/04: sf_table.dat, layer12.c
- Reported problem with use of (missing) scalefactor index 63.
Felix von Leitner <felix-mad@fefe.de>
2003/01/21: fixed.h
- Suggested Intel scaling alternative for possible speedup.
Andre McCurdy <armccurdy@yahoo.co.uk>
2000/08/10: imdct_l_arm.S
- ARM optimized assembly replacement for III_imdct_l().
2000/09/15: imdct_l_arm.S
- Applied Nicolas Pitre's rounding optimisation in all remaining
places.
2001/02/10: layer3.c
- Inspiration for Huffman decoding and requantization rewrite, and
other miscellany.
2001/03/24: imdct_l_arm.S
- Corrected PIC unsafe code.
2002/02/16: fixed.h
- Discovered bug in ARM version of mad_f_scale64().
Haruhiko OGASAWARA <theta@m1.interq.or.jp>
2001/01/28: layer3.c
- Reported discrepancy in alias reduction for mixed short blocks.
Brett Paterson <brett@fmod.org>
2001/10/28: global.h
- Reported missing <assert.h> et al. under MS Embedded Visual C.
Sean 'Shaleh' Perry <shaleh@via.net>
2000/04/04: fixed.h
- Suggested use of size-dependent typedefs.
2001/10/22: config.guess, config.sub
- Keep up to date for proper Debian packaging.
Bertrand Petit <eemad@phoe.frmug.org>
2001/11/05: synth.h
- Suggested PCM channel enumeration constants.
2001/11/05: stream.h
- Suggested MAD_ERROR_NONE enumeration constant.
2001/11/05: stream.c
- Suggested mad_stream_errorstr() function.
Nicolas Pitre <nico@cam.org>
2000/09/09: fixed.h
- Parameterized all scaling for correct use of all multiplication
methods within mad_synth_frame().
- Rewrote the FPM_ARM version of mad_f_mul() so we have 64-bit
multiplication result, rounding and scaling with 3 instructions.
2000/09/09: imdct_l_arm.S
- Optimized rounding + scaling operations.
2000/09/17: synth.c
- Changed D[] run-time shifts to compile-time.
- Modified synthesis for better multiply/accumulate code output.
2001/08/11: fixed.h, synth.c
- Suggested 64-bit FPM negation and negative term factorization
during synthesis.
2001/08/11: fixed.h
- Suggested unrounded behavior for FPM_DEFAULT when OPT_SPEED.
2001/11/19: fixed.c
- Suggested computation of any resampling ratio.
===============================================================================
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment