Built SDL2_image and _mixer static

This commit is contained in:
2022-09-30 15:49:16 -04:00
parent e2605bf6c1
commit 1dec4347e0
4473 changed files with 1964551 additions and 9 deletions

View File

@ -0,0 +1,60 @@
# metaflac - Command-line FLAC metadata editor
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bin_PROGRAMS = metaflac
AM_CFLAGS = @OGG_CFLAGS@
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
metaflac.vcproj \
metaflac.vcxproj \
metaflac.vcxproj.filters
metaflac_SOURCES = \
main.c \
operations.c \
operations_shorthand_cuesheet.c \
operations_shorthand_picture.c \
operations_shorthand_seektable.c \
operations_shorthand_streaminfo.c \
operations_shorthand_vorbiscomment.c \
options.c \
usage.c \
utils.c \
operations.h \
operations_shorthand.h \
options.h \
usage.h \
utils.h
metaflac_LDFLAGS = $(AM_LDFLAGS)
if OS_IS_WINDOWS
win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
endif
metaflac_LDADD = \
$(top_builddir)/src/share/grabbag/libgrabbag.la \
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
$(top_builddir)/src/share/getopt/libgetopt.la \
$(top_builddir)/src/share/utf8/libutf8.la \
$(top_builddir)/src/libFLAC/libFLAC.la \
$(win_utf8_lib) \
@LIBICONV@
CLEANFILES = metaflac.exe

View File

@ -0,0 +1,750 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# metaflac - Command-line FLAC metadata editor
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = metaflac$(EXEEXT)
subdir = src/metaflac
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/add_cflags.m4 \
$(top_srcdir)/m4/add_cxxflags.m4 $(top_srcdir)/m4/bswap.m4 \
$(top_srcdir)/m4/clang.m4 $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/gcc_version.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/ogg.m4 $(top_srcdir)/m4/really_gcc.m4 \
$(top_srcdir)/m4/stack_protect.m4 $(top_srcdir)/m4/xmms.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_metaflac_OBJECTS = main.$(OBJEXT) operations.$(OBJEXT) \
operations_shorthand_cuesheet.$(OBJEXT) \
operations_shorthand_picture.$(OBJEXT) \
operations_shorthand_seektable.$(OBJEXT) \
operations_shorthand_streaminfo.$(OBJEXT) \
operations_shorthand_vorbiscomment.$(OBJEXT) options.$(OBJEXT) \
usage.$(OBJEXT) utils.$(OBJEXT)
metaflac_OBJECTS = $(am_metaflac_OBJECTS)
metaflac_DEPENDENCIES = \
$(top_builddir)/src/share/grabbag/libgrabbag.la \
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
$(top_builddir)/src/share/getopt/libgetopt.la \
$(top_builddir)/src/share/utf8/libutf8.la \
$(top_builddir)/src/libFLAC/libFLAC.la $(win_utf8_lib)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
metaflac_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(metaflac_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(metaflac_SOURCES)
DIST_SOURCES = $(metaflac_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@
DOXYGEN = @DOXYGEN@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ENABLE_64_BIT_WORDS = @ENABLE_64_BIT_WORDS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FLAC__HAS_OGG = @FLAC__HAS_OGG@
FLAC__TEST_LEVEL = @FLAC__TEST_LEVEL@
FLAC__TEST_WITH_VALGRIND = @FLAC__TEST_WITH_VALGRIND@
GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@
GCC_MINOR_VERSION = @GCC_MINOR_VERSION@
GCC_VERSION = @GCC_VERSION@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NASM = @NASM@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OBJ_FORMAT = @OBJ_FORMAT@
OGG_CFLAGS = @OGG_CFLAGS@
OGG_LIBS = @OGG_LIBS@
OGG_PACKAGE = @OGG_PACKAGE@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XMMS_CFLAGS = @XMMS_CFLAGS@
XMMS_CONFIG = @XMMS_CONFIG@
XMMS_DATA_DIR = @XMMS_DATA_DIR@
XMMS_EFFECT_PLUGIN_DIR = @XMMS_EFFECT_PLUGIN_DIR@
XMMS_GENERAL_PLUGIN_DIR = @XMMS_GENERAL_PLUGIN_DIR@
XMMS_INPUT_PLUGIN_DIR = @XMMS_INPUT_PLUGIN_DIR@
XMMS_LIBS = @XMMS_LIBS@
XMMS_OUTPUT_PLUGIN_DIR = @XMMS_OUTPUT_PLUGIN_DIR@
XMMS_PLUGIN_DIR = @XMMS_PLUGIN_DIR@
XMMS_VERSION = @XMMS_VERSION@
XMMS_VISUALIZATION_PLUGIN_DIR = @XMMS_VISUALIZATION_PLUGIN_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CFLAGS = @OGG_CFLAGS@
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
metaflac.vcproj \
metaflac.vcxproj \
metaflac.vcxproj.filters
metaflac_SOURCES = \
main.c \
operations.c \
operations_shorthand_cuesheet.c \
operations_shorthand_picture.c \
operations_shorthand_seektable.c \
operations_shorthand_streaminfo.c \
operations_shorthand_vorbiscomment.c \
options.c \
usage.c \
utils.c \
operations.h \
operations_shorthand.h \
options.h \
usage.h \
utils.h
metaflac_LDFLAGS = $(AM_LDFLAGS)
@OS_IS_WINDOWS_TRUE@win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
metaflac_LDADD = \
$(top_builddir)/src/share/grabbag/libgrabbag.la \
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
$(top_builddir)/src/share/getopt/libgetopt.la \
$(top_builddir)/src/share/utf8/libutf8.la \
$(top_builddir)/src/libFLAC/libFLAC.la \
$(win_utf8_lib) \
@LIBICONV@
CLEANFILES = metaflac.exe
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/metaflac/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/metaflac/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
metaflac$(EXEEXT): $(metaflac_OBJECTS) $(metaflac_DEPENDENCIES) $(EXTRA_metaflac_DEPENDENCIES)
@rm -f metaflac$(EXEEXT)
$(AM_V_CCLD)$(metaflac_LINK) $(metaflac_OBJECTS) $(metaflac_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operations.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operations_shorthand_cuesheet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operations_shorthand_picture.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operations_shorthand_seektable.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operations_shorthand_streaminfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operations_shorthand_vorbiscomment.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,56 @@
# metaflac - Command-line FLAC metadata editor
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# GNU makefile
#
topdir = ../..
include $(topdir)/build/config.mk
libdir = $(topdir)/objs/$(BUILD)/lib
PROGRAM_NAME = metaflac
INCLUDES = -I./include -I$(topdir)/include $(OGG_INCLUDES)
ifeq ($(OS),Darwin)
EXPLICIT_LIBS = $(libdir)/libgrabbag.a $(libdir)/libFLAC.a $(libdir)/libreplaygain_analysis.a $(libdir)/libgetopt.a $(libdir)/libutf8.a $(OGG_EXPLICIT_LIBS) $(ICONV_LIBS) -lm
else
ifeq ($(findstring Windows,$(OS)),Windows)
LIBS = -lgrabbag -lFLAC -lreplaygain_analysis -lgetopt -lutf8 -lgrabbag -lwin_utf8_io $(OGG_LIBS) -lm
else
LIBS = -lgrabbag -lFLAC -lreplaygain_analysis -lgetopt -lutf8 -lgrabbag $(OGG_LIBS) -lm
endif
endif
SRCS_C = \
main.c \
operations.c \
operations_shorthand_cuesheet.c \
operations_shorthand_picture.c \
operations_shorthand_seektable.c \
operations_shorthand_streaminfo.c \
operations_shorthand_vorbiscomment.c \
options.c \
usage.c \
utils.c
include $(topdir)/build/exe.mk
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -0,0 +1,71 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "operations.h"
#include "options.h"
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include "share/compat.h"
int main(int argc, char *argv[])
{
CommandLineOptions options;
int ret = 0;
#ifdef __EMX__
_response(&argc, &argv);
_wildcard(&argc, &argv);
#endif
#ifdef _WIN32
if (get_utf8_argv(&argc, &argv) != 0) {
fputs("ERROR: failed to convert command line parameters to UTF-8\n", stderr);
return 1;
}
#endif
#ifdef _WIN32
{
const char *var;
var = getenv("LC_ALL");
if (!var)
var = getenv("LC_NUMERIC");
if (!var)
var = getenv("LANG");
if (!var || strcmp(var, "C") != 0)
setlocale(LC_ALL, "");
}
#else
setlocale(LC_ALL, "");
#endif
init_options(&options);
if ((ret = parse_options(argc, argv, &options)) == 0)
ret = !do_operations(&options);
else
ret = 1;
free_options(&options);
return ret;
}

View File

@ -0,0 +1,251 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="metaflac"
ProjectGUID="{4cefbc87-c215-11db-8314-0800200c9a66}"
RootNamespace="metaflac"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)objs\$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="0"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)objs\$(ConfigurationName)\lib\libogg_static.lib"
LinkIncremental="2"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)objs\$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="0"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)objs\$(ConfigurationName)\lib\libogg_static.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\operations.h"
>
</File>
<File
RelativePath=".\options.h"
>
</File>
<File
RelativePath=".\usage.h"
>
</File>
<File
RelativePath=".\utils.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\main.c"
>
</File>
<File
RelativePath=".\operations.c"
>
</File>
<File
RelativePath=".\operations_shorthand_cuesheet.c"
>
</File>
<File
RelativePath=".\operations_shorthand_picture.c"
>
</File>
<File
RelativePath=".\operations_shorthand_seektable.c"
>
</File>
<File
RelativePath=".\operations_shorthand_streaminfo.c"
>
</File>
<File
RelativePath=".\operations_shorthand_vorbiscomment.c"
>
</File>
<File
RelativePath=".\options.c"
>
</File>
<File
RelativePath=".\usage.c"
>
</File>
<File
RelativePath=".\utils.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4cefbc87-c215-11db-8314-0800200c9a66}</ProjectGuid>
<RootNamespace>metaflac</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)objs\$(Configuration)\bin\</OutDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)objs\$(Platform)\$(Configuration)\bin\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)objs\$(Configuration)\bin\</OutDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)objs\$(Platform)\$(Configuration)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Platform)\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Platform)\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="operations.h" />
<ClInclude Include="options.h" />
<ClInclude Include="usage.h" />
<ClInclude Include="utils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c" />
<ClCompile Include="operations.c" />
<ClCompile Include="operations_shorthand_cuesheet.c" />
<ClCompile Include="operations_shorthand_picture.c" />
<ClCompile Include="operations_shorthand_seektable.c" />
<ClCompile Include="operations_shorthand_streaminfo.c" />
<ClCompile Include="operations_shorthand_vorbiscomment.c" />
<ClCompile Include="options.c" />
<ClCompile Include="usage.c" />
<ClCompile Include="utils.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\libFLAC\libFLAC_static.vcxproj">
<Project>{4cefbc84-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\getopt\getopt_static.vcxproj">
<Project>{4cefbc80-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\grabbag\grabbag_static.vcxproj">
<Project>{4cefbc81-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\replaygain_analysis\replaygain_analysis_static.vcxproj">
<Project>{4cefbc89-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\utf8\utf8_static.vcxproj">
<Project>{4cefbc92-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\win_utf8_io\win_utf8_io_static.vcxproj">
<Project>{4cefbe02-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="operations.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="options.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="usage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utils.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="operations.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="operations_shorthand_cuesheet.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="operations_shorthand_picture.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="operations_shorthand_seektable.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="operations_shorthand_streaminfo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="operations_shorthand_vorbiscomment.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="options.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="usage.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="utils.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,671 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "operations.h"
#include "usage.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "share/alloc.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "operations_shorthand.h"
static void show_version(void);
static FLAC__bool do_major_operation(const CommandLineOptions *options);
static FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options);
static FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain *chain, const CommandLineOptions *options);
static FLAC__bool do_major_operation__append(FLAC__Metadata_Chain *chain, const CommandLineOptions *options);
static FLAC__bool do_major_operation__remove(FLAC__Metadata_Chain *chain, const CommandLineOptions *options);
static FLAC__bool do_major_operation__remove_all(FLAC__Metadata_Chain *chain, const CommandLineOptions *options);
static FLAC__bool do_shorthand_operations(const CommandLineOptions *options);
static FLAC__bool do_shorthand_operations_on_file(const char *filename, const CommandLineOptions *options);
static FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool utf8_convert);
static FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime, FLAC__bool scan);
static FLAC__bool do_shorthand_operation__add_padding(const char *filename, FLAC__Metadata_Chain *chain, unsigned length, FLAC__bool *needs_write);
static FLAC__bool passes_filter(const CommandLineOptions *options, const FLAC__StreamMetadata *block, unsigned block_number);
static void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned block_number, FLAC__bool raw, FLAC__bool hexdump_application);
/* from operations_shorthand_seektable.c */
extern FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write);
/* from operations_shorthand_streaminfo.c */
extern FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
/* from operations_shorthand_vorbiscomment.c */
extern FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw);
/* from operations_shorthand_cuesheet.c */
extern FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
/* from operations_shorthand_picture.c */
extern FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
FLAC__bool do_operations(const CommandLineOptions *options)
{
FLAC__bool ok = true;
if(options->show_long_help) {
long_usage(0);
}
if(options->show_version) {
show_version();
}
else if(options->args.checks.num_major_ops > 0) {
FLAC__ASSERT(options->args.checks.num_shorthand_ops == 0);
FLAC__ASSERT(options->args.checks.num_major_ops == 1);
FLAC__ASSERT(options->args.checks.num_major_ops == options->ops.num_operations);
ok = do_major_operation(options);
}
else if(options->args.checks.num_shorthand_ops > 0) {
FLAC__ASSERT(options->args.checks.num_shorthand_ops == options->ops.num_operations);
ok = do_shorthand_operations(options);
}
return ok;
}
/*
* local routines
*/
void show_version(void)
{
printf("metaflac %s\n", FLAC__VERSION_STRING);
}
FLAC__bool do_major_operation(const CommandLineOptions *options)
{
unsigned i;
FLAC__bool ok = true;
/* to die after first error, v--- add '&& ok' here */
for(i = 0; i < options->num_files; i++)
ok &= do_major_operation_on_file(options->filenames[i], options);
return ok;
}
FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options)
{
FLAC__bool ok = true, needs_write = false, is_ogg = false;
FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new();
if(0 == chain)
die("out of memory allocating chain");
/*@@@@ lame way of guessing the file type */
if(strlen(filename) >= 4 && (0 == strcmp(filename+strlen(filename)-4, ".oga") || 0 == strcmp(filename+strlen(filename)-4, ".ogg")))
is_ogg = true;
if(! (is_ogg? FLAC__metadata_chain_read_ogg(chain, filename) : FLAC__metadata_chain_read(chain, filename)) ) {
print_error_with_chain_status(chain, "%s: ERROR: reading metadata", filename);
FLAC__metadata_chain_delete(chain);
return false;
}
switch(options->ops.operations[0].type) {
case OP__LIST:
ok = do_major_operation__list(options->prefix_with_filename? filename : 0, chain, options);
break;
case OP__APPEND:
ok = do_major_operation__append(chain, options);
needs_write = true;
break;
case OP__REMOVE:
ok = do_major_operation__remove(chain, options);
needs_write = true;
break;
case OP__REMOVE_ALL:
ok = do_major_operation__remove_all(chain, options);
needs_write = true;
break;
case OP__MERGE_PADDING:
FLAC__metadata_chain_merge_padding(chain);
needs_write = true;
break;
case OP__SORT_PADDING:
FLAC__metadata_chain_sort_padding(chain);
needs_write = true;
break;
default:
FLAC__ASSERT(0);
return false;
}
if(ok && needs_write) {
if(options->use_padding)
FLAC__metadata_chain_sort_padding(chain);
ok = FLAC__metadata_chain_write(chain, options->use_padding, options->preserve_modtime);
if(!ok)
print_error_with_chain_status(chain, "%s: ERROR: writing FLAC file", filename);
}
FLAC__metadata_chain_delete(chain);
return ok;
}
FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain *chain, const CommandLineOptions *options)
{
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
FLAC__StreamMetadata *block;
FLAC__bool ok = true;
unsigned block_number;
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
block_number = 0;
do {
block = FLAC__metadata_iterator_get_block(iterator);
ok &= (0 != block);
if(!ok)
flac_fprintf(stderr, "%s: ERROR: couldn't get block from chain\n", filename);
else if(passes_filter(options, FLAC__metadata_iterator_get_block(iterator), block_number))
write_metadata(filename, block, block_number, !options->utf8_convert, options->application_data_format_is_hexdump);
block_number++;
} while(ok && FLAC__metadata_iterator_next(iterator));
FLAC__metadata_iterator_delete(iterator);
return ok;
}
FLAC__bool do_major_operation__append(FLAC__Metadata_Chain *chain, const CommandLineOptions *options)
{
(void) chain, (void) options;
flac_fprintf(stderr, "ERROR: --append not implemented yet\n");
return false;
}
FLAC__bool do_major_operation__remove(FLAC__Metadata_Chain *chain, const CommandLineOptions *options)
{
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
FLAC__bool ok = true;
unsigned block_number;
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
block_number = 0;
while(ok && FLAC__metadata_iterator_next(iterator)) {
block_number++;
if(passes_filter(options, FLAC__metadata_iterator_get_block(iterator), block_number)) {
ok &= FLAC__metadata_iterator_delete_block(iterator, options->use_padding);
if(options->use_padding)
ok &= FLAC__metadata_iterator_next(iterator);
}
}
FLAC__metadata_iterator_delete(iterator);
return ok;
}
FLAC__bool do_major_operation__remove_all(FLAC__Metadata_Chain *chain, const CommandLineOptions *options)
{
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
FLAC__bool ok = true;
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
while(ok && FLAC__metadata_iterator_next(iterator)) {
ok &= FLAC__metadata_iterator_delete_block(iterator, options->use_padding);
if(options->use_padding)
ok &= FLAC__metadata_iterator_next(iterator);
}
FLAC__metadata_iterator_delete(iterator);
return ok;
}
FLAC__bool do_shorthand_operations(const CommandLineOptions *options)
{
unsigned i;
FLAC__bool ok = true;
/* to die after first error, v--- add '&& ok' here */
for(i = 0; i < options->num_files; i++)
ok &= do_shorthand_operations_on_file(options->filenames[i], options);
/* check if OP__ADD_REPLAY_GAIN requested */
if(ok && options->num_files > 0) {
for(i = 0; i < options->ops.num_operations; i++) {
if(options->ops.operations[i].type == OP__ADD_REPLAY_GAIN)
ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime, false);
else if(options->ops.operations[i].type == OP__SCAN_REPLAY_GAIN)
ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime, true);
}
}
return ok;
}
FLAC__bool do_shorthand_operations_on_file(const char *filename, const CommandLineOptions *options)
{
unsigned i;
FLAC__bool ok = true, needs_write = false, use_padding = options->use_padding;
FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new();
if(0 == chain)
die("out of memory allocating chain");
if(!FLAC__metadata_chain_read(chain, filename)) {
print_error_with_chain_status(chain, "%s: ERROR: reading metadata", filename);
return false;
}
for(i = 0; i < options->ops.num_operations && ok; i++) {
/*
* Do OP__ADD_SEEKPOINT last to avoid decoding twice if both
* --add-seekpoint and --import-cuesheet-from are used.
*/
if(options->ops.operations[i].type != OP__ADD_SEEKPOINT)
ok &= do_shorthand_operation(filename, options->prefix_with_filename, chain, &options->ops.operations[i], &needs_write, options->utf8_convert);
/* The following seems counterintuitive but the meaning
* of 'use_padding' is 'try to keep the overall metadata
* to its original size, adding or truncating extra
* padding if necessary' which is why we need to turn it
* off in this case. If we don't, the extra padding block
* will just be truncated.
*/
if(options->ops.operations[i].type == OP__ADD_PADDING)
use_padding = false;
}
/*
* Do OP__ADD_SEEKPOINT last to avoid decoding twice if both
* --add-seekpoint and --import-cuesheet-from are used.
*/
for(i = 0; i < options->ops.num_operations && ok; i++) {
if(options->ops.operations[i].type == OP__ADD_SEEKPOINT)
ok &= do_shorthand_operation(filename, options->prefix_with_filename, chain, &options->ops.operations[i], &needs_write, options->utf8_convert);
}
if(ok && needs_write) {
if(use_padding)
FLAC__metadata_chain_sort_padding(chain);
ok = FLAC__metadata_chain_write(chain, use_padding, options->preserve_modtime);
if(!ok)
print_error_with_chain_status(chain, "%s: ERROR: writing FLAC file", filename);
}
FLAC__metadata_chain_delete(chain);
return ok;
}
FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool utf8_convert)
{
FLAC__bool ok = true;
switch(operation->type) {
case OP__SHOW_MD5SUM:
case OP__SHOW_MIN_BLOCKSIZE:
case OP__SHOW_MAX_BLOCKSIZE:
case OP__SHOW_MIN_FRAMESIZE:
case OP__SHOW_MAX_FRAMESIZE:
case OP__SHOW_SAMPLE_RATE:
case OP__SHOW_CHANNELS:
case OP__SHOW_BPS:
case OP__SHOW_TOTAL_SAMPLES:
case OP__SET_MD5SUM:
case OP__SET_MIN_BLOCKSIZE:
case OP__SET_MAX_BLOCKSIZE:
case OP__SET_MIN_FRAMESIZE:
case OP__SET_MAX_FRAMESIZE:
case OP__SET_SAMPLE_RATE:
case OP__SET_CHANNELS:
case OP__SET_BPS:
case OP__SET_TOTAL_SAMPLES:
ok = do_shorthand_operation__streaminfo(filename, prefix_with_filename, chain, operation, needs_write);
break;
case OP__SHOW_VC_VENDOR:
case OP__SHOW_VC_FIELD:
case OP__REMOVE_VC_ALL:
case OP__REMOVE_VC_FIELD:
case OP__REMOVE_VC_FIRSTFIELD:
case OP__SET_VC_FIELD:
case OP__IMPORT_VC_FROM:
case OP__EXPORT_VC_TO:
ok = do_shorthand_operation__vorbis_comment(filename, prefix_with_filename, chain, operation, needs_write, !utf8_convert);
break;
case OP__IMPORT_CUESHEET_FROM:
case OP__EXPORT_CUESHEET_TO:
ok = do_shorthand_operation__cuesheet(filename, chain, operation, needs_write);
break;
case OP__IMPORT_PICTURE_FROM:
case OP__EXPORT_PICTURE_TO:
ok = do_shorthand_operation__picture(filename, chain, operation, needs_write);
break;
case OP__ADD_SEEKPOINT:
ok = do_shorthand_operation__add_seekpoints(filename, chain, operation->argument.add_seekpoint.specification, needs_write);
break;
case OP__ADD_REPLAY_GAIN:
case OP__SCAN_REPLAY_GAIN:
/* these commands are always executed last */
ok = true;
break;
case OP__ADD_PADDING:
ok = do_shorthand_operation__add_padding(filename, chain, operation->argument.add_padding.length, needs_write);
break;
default:
ok = false;
FLAC__ASSERT(0);
break;
};
return ok;
}
FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime, FLAC__bool scan)
{
FLAC__StreamMetadata streaminfo;
float *title_gains = 0, *title_peaks = 0;
float album_gain, album_peak;
unsigned sample_rate = 0;
unsigned bits_per_sample = 0;
unsigned channels = 0;
unsigned i;
const char *error;
FLAC__bool first = true;
FLAC__ASSERT(num_files > 0);
for(i = 0; i < num_files; i++) {
FLAC__ASSERT(0 != filenames[i]);
if(!FLAC__metadata_get_streaminfo(filenames[i], &streaminfo)) {
flac_fprintf(stderr, "%s: ERROR: can't open file or get STREAMINFO block\n", filenames[i]);
return false;
}
if(first) {
first = false;
sample_rate = streaminfo.data.stream_info.sample_rate;
bits_per_sample = streaminfo.data.stream_info.bits_per_sample;
channels = streaminfo.data.stream_info.channels;
}
else {
if(sample_rate != streaminfo.data.stream_info.sample_rate) {
flac_fprintf(stderr, "%s: ERROR: sample rate of %u Hz does not match previous files' %u Hz\n", filenames[i], streaminfo.data.stream_info.sample_rate, sample_rate);
return false;
}
if(bits_per_sample != streaminfo.data.stream_info.bits_per_sample) {
flac_fprintf(stderr, "%s: ERROR: resolution of %u bps does not match previous files' %u bps\n", filenames[i], streaminfo.data.stream_info.bits_per_sample, bits_per_sample);
return false;
}
if(channels != streaminfo.data.stream_info.channels) {
flac_fprintf(stderr, "%s: ERROR: # channels (%u) does not match previous files' (%u)\n", filenames[i], streaminfo.data.stream_info.channels, channels);
return false;
}
}
if(!grabbag__replaygain_is_valid_sample_frequency(sample_rate)) {
flac_fprintf(stderr, "%s: ERROR: sample rate of %u Hz is not supported\n", filenames[i], sample_rate);
return false;
}
if(channels != 1 && channels != 2) {
flac_fprintf(stderr, "%s: ERROR: # of channels (%u) is not supported, must be 1 or 2\n", filenames[i], channels);
return false;
}
}
FLAC__ASSERT(bits_per_sample >= FLAC__MIN_BITS_PER_SAMPLE && bits_per_sample <= FLAC__MAX_BITS_PER_SAMPLE);
if(!grabbag__replaygain_init(sample_rate)) {
FLAC__ASSERT(0);
/* double protection */
flac_fprintf(stderr, "internal error\n");
return false;
}
if(
0 == (title_gains = safe_malloc_mul_2op_(sizeof(float), /*times*/num_files)) ||
0 == (title_peaks = safe_malloc_mul_2op_(sizeof(float), /*times*/num_files))
)
die("out of memory allocating space for title gains/peaks");
for(i = 0; i < num_files; i++) {
if(0 != (error = grabbag__replaygain_analyze_file(filenames[i], title_gains+i, title_peaks+i))) {
flac_fprintf(stderr, "%s: ERROR: during analysis (%s)\n", filenames[i], error);
free(title_gains);
free(title_peaks);
return false;
}
}
grabbag__replaygain_get_album(&album_gain, &album_peak);
for(i = 0; i < num_files; i++) {
if(!scan) {
if(0 != (error = grabbag__replaygain_store_to_file(filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i], preserve_modtime))) {
flac_fprintf(stderr, "%s: ERROR: writing tags (%s)\n", filenames[i], error);
free(title_gains);
free(title_peaks);
return false;
}
} else {
flac_fprintf(stdout, "%s: %f %f %f %f\n", filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i]);
}
}
free(title_gains);
free(title_peaks);
return true;
}
FLAC__bool do_shorthand_operation__add_padding(const char *filename, FLAC__Metadata_Chain *chain, unsigned length, FLAC__bool *needs_write)
{
FLAC__StreamMetadata *padding = 0;
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
while(FLAC__metadata_iterator_next(iterator))
;
padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING);
if(0 == padding)
die("out of memory allocating PADDING block");
padding->length = length;
if(!FLAC__metadata_iterator_insert_block_after(iterator, padding)) {
print_error_with_chain_status(chain, "%s: ERROR: adding new PADDING block to metadata", filename);
FLAC__metadata_object_delete(padding);
FLAC__metadata_iterator_delete(iterator);
return false;
}
FLAC__metadata_iterator_delete(iterator);
*needs_write = true;
return true;
}
FLAC__bool passes_filter(const CommandLineOptions *options, const FLAC__StreamMetadata *block, unsigned block_number)
{
unsigned i, j;
FLAC__bool matches_number = false, matches_type = false;
FLAC__bool has_block_number_arg = false;
for(i = 0; i < options->args.num_arguments; i++) {
if(options->args.arguments[i].type == ARG__BLOCK_TYPE || options->args.arguments[i].type == ARG__EXCEPT_BLOCK_TYPE) {
for(j = 0; j < options->args.arguments[i].value.block_type.num_entries; j++) {
if(options->args.arguments[i].value.block_type.entries[j].type == block->type) {
if(block->type != FLAC__METADATA_TYPE_APPLICATION || !options->args.arguments[i].value.block_type.entries[j].filter_application_by_id || 0 == memcmp(options->args.arguments[i].value.block_type.entries[j].application_id, block->data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8))
matches_type = true;
}
}
}
else if(options->args.arguments[i].type == ARG__BLOCK_NUMBER) {
has_block_number_arg = true;
for(j = 0; j < options->args.arguments[i].value.block_number.num_entries; j++) {
if(options->args.arguments[i].value.block_number.entries[j] == block_number)
matches_number = true;
}
}
}
if(!has_block_number_arg)
matches_number = true;
if(options->args.checks.has_block_type) {
FLAC__ASSERT(!options->args.checks.has_except_block_type);
}
else if(options->args.checks.has_except_block_type)
matches_type = !matches_type;
else
matches_type = true;
return matches_number && matches_type;
}
void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned block_number, FLAC__bool raw, FLAC__bool hexdump_application)
{
unsigned i, j;
/*@@@ yuck, should do this with a varargs function or something: */
#define PPR if(filename) { if(raw) printf("%s:",filename); else flac_printf("%s:",filename); }
PPR; printf("METADATA block #%u\n", block_number);
PPR; printf(" type: %u (%s)\n", (unsigned)block->type, block->type < FLAC__METADATA_TYPE_UNDEFINED? FLAC__MetadataTypeString[block->type] : "UNKNOWN");
PPR; printf(" is last: %s\n", block->is_last? "true":"false");
PPR; printf(" length: %u\n", block->length);
switch(block->type) {
case FLAC__METADATA_TYPE_STREAMINFO:
PPR; printf(" minimum blocksize: %u samples\n", block->data.stream_info.min_blocksize);
PPR; printf(" maximum blocksize: %u samples\n", block->data.stream_info.max_blocksize);
PPR; printf(" minimum framesize: %u bytes\n", block->data.stream_info.min_framesize);
PPR; printf(" maximum framesize: %u bytes\n", block->data.stream_info.max_framesize);
PPR; printf(" sample_rate: %u Hz\n", block->data.stream_info.sample_rate);
PPR; printf(" channels: %u\n", block->data.stream_info.channels);
PPR; printf(" bits-per-sample: %u\n", block->data.stream_info.bits_per_sample);
PPR; printf(" total samples: %" PRIu64 "\n", block->data.stream_info.total_samples);
PPR; printf(" MD5 signature: ");
for(i = 0; i < 16; i++) {
printf("%02x", (unsigned)block->data.stream_info.md5sum[i]);
}
printf("\n");
break;
case FLAC__METADATA_TYPE_PADDING:
/* nothing to print */
break;
case FLAC__METADATA_TYPE_APPLICATION:
PPR; printf(" application ID: ");
for(i = 0; i < 4; i++)
printf("%02x", block->data.application.id[i]);
printf("\n");
PPR; printf(" data contents:\n");
if(0 != block->data.application.data) {
if(hexdump_application)
hexdump(filename, block->data.application.data, block->length - FLAC__STREAM_METADATA_HEADER_LENGTH, " ");
else
(void) local_fwrite(block->data.application.data, 1, block->length - FLAC__STREAM_METADATA_HEADER_LENGTH, stdout);
}
break;
case FLAC__METADATA_TYPE_SEEKTABLE:
PPR; printf(" seek points: %u\n", block->data.seek_table.num_points);
for(i = 0; i < block->data.seek_table.num_points; i++) {
if(block->data.seek_table.points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
PPR; printf(" point %u: sample_number=%" PRIu64 ", stream_offset=%" PRIu64 ", frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
}
else {
PPR; printf(" point %u: PLACEHOLDER\n", i);
}
}
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
PPR; printf(" vendor string: ");
write_vc_field(0, &block->data.vorbis_comment.vendor_string, raw, stdout);
PPR; printf(" comments: %u\n", block->data.vorbis_comment.num_comments);
for(i = 0; i < block->data.vorbis_comment.num_comments; i++) {
PPR; printf(" comment[%u]: ", i);
write_vc_field(0, &block->data.vorbis_comment.comments[i], raw, stdout);
}
break;
case FLAC__METADATA_TYPE_CUESHEET:
PPR; printf(" media catalog number: %s\n", block->data.cue_sheet.media_catalog_number);
PPR; printf(" lead-in: %" PRIu64 "\n", block->data.cue_sheet.lead_in);
PPR; printf(" is CD: %s\n", block->data.cue_sheet.is_cd? "true":"false");
PPR; printf(" number of tracks: %u\n", block->data.cue_sheet.num_tracks);
for(i = 0; i < block->data.cue_sheet.num_tracks; i++) {
const FLAC__StreamMetadata_CueSheet_Track *track = block->data.cue_sheet.tracks+i;
const FLAC__bool is_last = (i == block->data.cue_sheet.num_tracks-1);
const FLAC__bool is_leadout = is_last && track->num_indices == 0;
PPR; printf(" track[%u]\n", i);
PPR; printf(" offset: %" PRIu64 "\n", track->offset);
if(is_last) {
PPR; printf(" number: %u (%s)\n", (unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID");
}
else {
PPR; printf(" number: %u\n", (unsigned)track->number);
}
if(!is_leadout) {
PPR; printf(" ISRC: %s\n", track->isrc);
PPR; printf(" type: %s\n", track->type == 1? "DATA" : "AUDIO");
PPR; printf(" pre-emphasis: %s\n", track->pre_emphasis? "true":"false");
PPR; printf(" number of index points: %u\n", track->num_indices);
for(j = 0; j < track->num_indices; j++) {
const FLAC__StreamMetadata_CueSheet_Index *indx = track->indices+j;
PPR; printf(" index[%u]\n", j);
PPR; printf(" offset: %" PRIu64 "\n", indx->offset);
PPR; printf(" number: %u\n", (unsigned)indx->number);
}
}
}
break;
case FLAC__METADATA_TYPE_PICTURE:
PPR; printf(" type: %u (%s)\n", block->data.picture.type, block->data.picture.type < FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED? FLAC__StreamMetadata_Picture_TypeString[block->data.picture.type] : "UNDEFINED");
PPR; printf(" MIME type: %s\n", block->data.picture.mime_type);
PPR; printf(" description: %s\n", block->data.picture.description);
PPR; printf(" width: %u\n", (unsigned)block->data.picture.width);
PPR; printf(" height: %u\n", (unsigned)block->data.picture.height);
PPR; printf(" depth: %u\n", (unsigned)block->data.picture.depth);
PPR; printf(" colors: %u%s\n", (unsigned)block->data.picture.colors, block->data.picture.colors? "" : " (unindexed)");
PPR; printf(" data length: %u\n", (unsigned)block->data.picture.data_length);
PPR; printf(" data:\n");
if(0 != block->data.picture.data)
hexdump(filename, block->data.picture.data, block->data.picture.data_length, " ");
break;
default:
PPR; printf(" data contents:\n");
if(0 != block->data.unknown.data)
hexdump(filename, block->data.unknown.data, block->length, " ");
break;
}
#undef PPR
}

View File

@ -0,0 +1,27 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef metaflac__operations_h
#define metaflac__operations_h
#include "options.h"
FLAC__bool do_operations(const CommandLineOptions *options);
#endif

View File

@ -0,0 +1,26 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "options.h"
FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write);
FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw);

View File

@ -0,0 +1,214 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include "options.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include "operations_shorthand.h"
static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link);
static FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename);
FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
{
FLAC__bool ok = true;
FLAC__StreamMetadata *cuesheet = 0;
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
FLAC__uint64 lead_out_offset = 0;
FLAC__bool is_cdda = false;
unsigned sample_rate = 0;
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
do {
FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator);
if(block->type == FLAC__METADATA_TYPE_STREAMINFO) {
lead_out_offset = block->data.stream_info.total_samples;
if(lead_out_offset == 0) {
flac_fprintf(stderr, "%s: ERROR: FLAC file must have total_samples set in STREAMINFO in order to import/export cuesheet\n", filename);
FLAC__metadata_iterator_delete(iterator);
return false;
}
sample_rate = block->data.stream_info.sample_rate;
is_cdda = (block->data.stream_info.channels == 1 || block->data.stream_info.channels == 2) && (block->data.stream_info.bits_per_sample == 16) && (sample_rate == 44100);
}
else if(block->type == FLAC__METADATA_TYPE_CUESHEET)
cuesheet = block;
} while(FLAC__metadata_iterator_next(iterator));
if(lead_out_offset == 0) {
flac_fprintf(stderr, "%s: ERROR: FLAC stream has no STREAMINFO block\n", filename);
FLAC__metadata_iterator_delete(iterator);
return false;
}
switch(operation->type) {
case OP__IMPORT_CUESHEET_FROM:
if(0 != cuesheet) {
flac_fprintf(stderr, "%s: ERROR: FLAC file already has CUESHEET block\n", filename);
ok = false;
}
else {
ok = import_cs_from(filename, &cuesheet, operation->argument.import_cuesheet_from.filename, needs_write, lead_out_offset, sample_rate, is_cdda, operation->argument.import_cuesheet_from.add_seekpoint_link);
if(ok) {
/* append CUESHEET block */
while(FLAC__metadata_iterator_next(iterator))
;
if(!FLAC__metadata_iterator_insert_block_after(iterator, cuesheet)) {
print_error_with_chain_status(chain, "%s: ERROR: adding new CUESHEET block to metadata", filename);
FLAC__metadata_object_delete(cuesheet);
ok = false;
}
}
}
break;
case OP__EXPORT_CUESHEET_TO:
if(0 == cuesheet) {
flac_fprintf(stderr, "%s: ERROR: FLAC file has no CUESHEET block\n", filename);
ok = false;
}
else
ok = export_cs_to(filename, cuesheet, operation->argument.filename.value);
break;
default:
ok = false;
FLAC__ASSERT(0);
break;
};
FLAC__metadata_iterator_delete(iterator);
return ok;
}
/*
* local routines
*/
FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link)
{
FILE *f;
const char *error_message;
char **seekpoint_specification = add_seekpoint_link? &(add_seekpoint_link->specification) : 0;
unsigned last_line_read;
if(0 == cs_filename || strlen(cs_filename) == 0) {
flac_fprintf(stderr, "%s: ERROR: empty import file name\n", filename);
return false;
}
if(0 == strcmp(cs_filename, "-"))
f = stdin;
else
f = flac_fopen(cs_filename, "r");
if(0 == f) {
flac_fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, cs_filename, strerror(errno));
return false;
}
*cuesheet = grabbag__cuesheet_parse(f, &error_message, &last_line_read, sample_rate, is_cdda, lead_out_offset);
if(f != stdin)
fclose(f);
if(0 == *cuesheet) {
flac_fprintf(stderr, "%s: ERROR: while parsing cuesheet \"%s\" on line %u: %s\n", filename, cs_filename, last_line_read, error_message);
return false;
}
if(!FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/false, &error_message)) {
flac_fprintf(stderr, "%s: ERROR parsing cuesheet \"%s\": %s\n", filename, cs_filename, error_message);
return false;
}
/* if we're expecting CDDA, warn about non-compliance */
if(is_cdda && !FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/true, &error_message)) {
flac_fprintf(stderr, "%s: WARNING cuesheet \"%s\" is not audio CD compliant: %s\n", filename, cs_filename, error_message);
(*cuesheet)->data.cue_sheet.is_cd = false;
}
/* add seekpoints for each index point if required */
if(0 != seekpoint_specification) {
char spec[128];
unsigned track, indx;
const FLAC__StreamMetadata_CueSheet *cs = &(*cuesheet)->data.cue_sheet;
if(0 == *seekpoint_specification)
*seekpoint_specification = local_strdup("");
for(track = 0; track < cs->num_tracks; track++) {
const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+track;
for(indx = 0; indx < tr->num_indices; indx++) {
flac_snprintf(spec, sizeof (spec), "%" PRIu64 ";", (tr->offset + tr->indices[indx].offset));
local_strcat(seekpoint_specification, spec);
}
}
}
*needs_write = true;
return true;
}
FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename)
{
FILE *f;
char *ref = 0;
size_t reflen;
if(0 == cs_filename || strlen(cs_filename) == 0) {
flac_fprintf(stderr, "%s: ERROR: empty export file name\n", filename);
return false;
}
if(0 == strcmp(cs_filename, "-"))
f = stdout;
else
f = flac_fopen(cs_filename, "w");
if(0 == f) {
flac_fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, cs_filename, strerror(errno));
return false;
}
reflen = strlen(filename) + 7 + 1;
if(0 == (ref = malloc(reflen))) {
flac_fprintf(stderr, "%s: ERROR: allocating memory\n", filename);
if(f != stdout)
fclose(f);
return false;
}
flac_snprintf(ref, reflen, "\"%s\" FLAC", filename);
grabbag__cuesheet_emit(f, cuesheet, ref);
free(ref);
if(f != stdout)
fclose(f);
return true;
}

View File

@ -0,0 +1,176 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include "options.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "share/grabbag.h" /* for grabbag__picture_parse_specification() etc */
#include "operations_shorthand.h"
static FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, const char *specification, FLAC__bool *needs_write);
static FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename);
FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
{
FLAC__bool ok = true, has_type1 = false, has_type2 = false;
FLAC__StreamMetadata *picture = 0;
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
switch(operation->type) {
case OP__IMPORT_PICTURE_FROM:
ok = import_pic_from(filename, &picture, operation->argument.specification.value, needs_write);
if(ok) {
/* append PICTURE block */
while(FLAC__metadata_iterator_next(iterator))
;
if(!FLAC__metadata_iterator_insert_block_after(iterator, picture)) {
print_error_with_chain_status(chain, "%s: ERROR: adding new PICTURE block to metadata", filename);
FLAC__metadata_object_delete(picture);
ok = false;
}
}
if(ok) {
/* check global PICTURE constraints (max 1 block each of type=1 and type=2) */
while(FLAC__metadata_iterator_prev(iterator))
;
do {
FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator);
if(block->type == FLAC__METADATA_TYPE_PICTURE) {
if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) {
if(has_type1) {
print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one 32x32 standard icon (type=1) PICTURE block", filename);
ok = false;
}
has_type1 = true;
}
else if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) {
if(has_type2) {
print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one icon (type=2) PICTURE block", filename);
ok = false;
}
has_type2 = true;
}
}
} while(FLAC__metadata_iterator_next(iterator));
}
break;
case OP__EXPORT_PICTURE_TO:
{
const Argument_BlockNumber *a = operation->argument.export_picture_to.block_number_link;
int block_number = (a && a->num_entries > 0)? (int)a->entries[0] : -1;
unsigned i = 0;
do {
FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator);
if(block->type == FLAC__METADATA_TYPE_PICTURE && (block_number < 0 || i == (unsigned)block_number))
picture = block;
i++;
} while(FLAC__metadata_iterator_next(iterator) && 0 == picture);
if(0 == picture) {
if(block_number < 0)
flac_fprintf(stderr, "%s: ERROR: FLAC file has no PICTURE block\n", filename);
else
flac_fprintf(stderr, "%s: ERROR: FLAC file has no PICTURE block at block #%d\n", filename, block_number);
ok = false;
}
else
ok = export_pic_to(filename, picture, operation->argument.filename.value);
}
break;
default:
ok = false;
FLAC__ASSERT(0);
break;
};
FLAC__metadata_iterator_delete(iterator);
return ok;
}
/*
* local routines
*/
FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, const char *specification, FLAC__bool *needs_write)
{
const char *error_message;
if(0 == specification || strlen(specification) == 0) {
flac_fprintf(stderr, "%s: ERROR: empty picture specification\n", filename);
return false;
}
*picture = grabbag__picture_parse_specification(specification, &error_message);
if(0 == *picture) {
flac_fprintf(stderr, "%s: ERROR: while parsing picture specification \"%s\": %s\n", filename, specification, error_message);
return false;
}
if(!FLAC__format_picture_is_legal(&(*picture)->data.picture, &error_message)) {
flac_fprintf(stderr, "%s: ERROR: new PICTURE block for \"%s\" is illegal: %s\n", filename, specification, error_message);
return false;
}
*needs_write = true;
return true;
}
FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename)
{
FILE *f;
const FLAC__uint32 len = picture->data.picture.data_length;
if(0 == pic_filename || strlen(pic_filename) == 0) {
flac_fprintf(stderr, "%s: ERROR: empty export file name\n", filename);
return false;
}
if(0 == strcmp(pic_filename, "-"))
f = grabbag__file_get_binary_stdout();
else
f = flac_fopen(pic_filename, "wb");
if(0 == f) {
flac_fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, pic_filename, strerror(errno));
return false;
}
if(fwrite(picture->data.picture.data, 1, len, f) != len) {
flac_fprintf(stderr, "%s: ERROR: writing PICTURE data to file\n", filename);
if(f != stdout)
fclose(f);
return false;
}
if(f != stdout)
fclose(f);
return true;
}

View File

@ -0,0 +1,218 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "utils.h"
#include "FLAC/assert.h"
#include "FLAC/stream_decoder.h"
#include "FLAC/metadata.h"
#include "share/grabbag.h"
#include "operations_shorthand.h"
static FLAC__bool populate_seekpoint_values(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write);
FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write)
{
FLAC__bool ok = true, found_seektable_block = false;
FLAC__StreamMetadata *block = 0;
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
FLAC__uint64 total_samples = 0;
unsigned sample_rate = 0;
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
do {
block = FLAC__metadata_iterator_get_block(iterator);
if(block->type == FLAC__METADATA_TYPE_STREAMINFO) {
sample_rate = block->data.stream_info.sample_rate;
total_samples = block->data.stream_info.total_samples;
}
else if(block->type == FLAC__METADATA_TYPE_SEEKTABLE)
found_seektable_block = true;
} while(!found_seektable_block && FLAC__metadata_iterator_next(iterator));
if(total_samples == 0) {
flac_fprintf(stderr, "%s: ERROR: cannot add seekpoints because STREAMINFO block does not specify total_samples\n", filename);
return false;
}
if(!found_seektable_block) {
/* create a new block */
block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE);
if(0 == block)
die("out of memory allocating SEEKTABLE block");
while(FLAC__metadata_iterator_prev(iterator))
;
if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) {
print_error_with_chain_status(chain, "%s: ERROR: adding new SEEKTABLE block to metadata", filename);
FLAC__metadata_object_delete(block);
return false;
}
/* iterator is left pointing to new block */
FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block);
}
FLAC__metadata_iterator_delete(iterator);
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_SEEKTABLE);
if(!grabbag__seektable_convert_specification_to_template(specification, /*only_explicit_placeholders=*/false, total_samples, sample_rate, block, /*spec_has_real_points=*/0)) {
flac_fprintf(stderr, "%s: ERROR (internal) preparing seektable with seekpoints\n", filename);
return false;
}
ok = populate_seekpoint_values(filename, block, needs_write);
if(ok)
(void) FLAC__format_seektable_sort(&block->data.seek_table);
return ok;
}
/*
* local routines
*/
typedef struct {
FLAC__StreamMetadata_SeekTable *seektable_template;
FLAC__uint64 samples_written;
FLAC__uint64 audio_offset, last_offset;
unsigned first_seekpoint_to_check;
FLAC__bool error_occurred;
FLAC__StreamDecoderErrorStatus error_status;
} ClientData;
static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
{
ClientData *cd = (ClientData*)client_data;
(void)buffer;
FLAC__ASSERT(0 != cd);
if(!cd->error_occurred) {
const unsigned blocksize = frame->header.blocksize;
const FLAC__uint64 frame_first_sample = cd->samples_written;
const FLAC__uint64 frame_last_sample = frame_first_sample + (FLAC__uint64)blocksize - 1;
FLAC__uint64 test_sample;
unsigned i;
for(i = cd->first_seekpoint_to_check; i < cd->seektable_template->num_points; i++) {
test_sample = cd->seektable_template->points[i].sample_number;
if(test_sample > frame_last_sample) {
break;
}
else if(test_sample >= frame_first_sample) {
cd->seektable_template->points[i].sample_number = frame_first_sample;
cd->seektable_template->points[i].stream_offset = cd->last_offset - cd->audio_offset;
cd->seektable_template->points[i].frame_samples = blocksize;
cd->first_seekpoint_to_check++;
/* DO NOT: "break;" and here's why:
* The seektable template may contain more than one target
* sample for any given frame; we will keep looping, generating
* duplicate seekpoints for them, and we'll clean it up later,
* just before writing the seektable back to the metadata.
*/
}
else {
cd->first_seekpoint_to_check++;
}
}
cd->samples_written += blocksize;
if(!FLAC__stream_decoder_get_decode_position(decoder, &cd->last_offset))
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
else
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
{
ClientData *cd = (ClientData*)client_data;
(void)decoder;
FLAC__ASSERT(0 != cd);
if(!cd->error_occurred) { /* don't let multiple errors overwrite the first one */
cd->error_occurred = true;
cd->error_status = status;
}
}
FLAC__bool populate_seekpoint_values(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write)
{
FLAC__StreamDecoder *decoder;
ClientData client_data;
FLAC__bool ok = true;
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_SEEKTABLE);
client_data.seektable_template = &block->data.seek_table;
client_data.samples_written = 0;
/* client_data.audio_offset must be determined later */
client_data.first_seekpoint_to_check = 0;
client_data.error_occurred = false;
decoder = FLAC__stream_decoder_new();
if(0 == decoder) {
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) creating the decoder instance\n", filename);
return false;
}
FLAC__stream_decoder_set_md5_checking(decoder, false);
FLAC__stream_decoder_set_metadata_ignore_all(decoder);
if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, /*metadata_callback=*/0, error_callback_, &client_data) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) initializing the decoder instance (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
ok = false;
}
if(ok && !FLAC__stream_decoder_process_until_end_of_metadata(decoder)) {
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
ok = false;
}
if(ok && !FLAC__stream_decoder_get_decode_position(decoder, &client_data.audio_offset)) {
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file\n", filename);
ok = false;
}
client_data.last_offset = client_data.audio_offset;
if(ok && !FLAC__stream_decoder_process_until_end_of_stream(decoder)) {
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
ok = false;
}
if(ok && client_data.error_occurred) {
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%u:%s)\n", filename, (unsigned)client_data.error_status, FLAC__StreamDecoderErrorStatusString[client_data.error_status]);
ok = false;
}
*needs_write = true;
FLAC__stream_decoder_delete(decoder);
return ok;
}

View File

@ -0,0 +1,127 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "options.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "share/compat.h"
#include <string.h>
#include "operations_shorthand.h"
FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
{
unsigned i;
FLAC__bool ok = true;
FLAC__StreamMetadata *block;
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
block = FLAC__metadata_iterator_get_block(iterator);
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_STREAMINFO);
if(prefix_with_filename)
flac_printf("%s:", filename);
switch(operation->type) {
case OP__SHOW_MD5SUM:
for(i = 0; i < 16; i++)
printf("%02x", block->data.stream_info.md5sum[i]);
printf("\n");
break;
case OP__SHOW_MIN_BLOCKSIZE:
printf("%u\n", block->data.stream_info.min_blocksize);
break;
case OP__SHOW_MAX_BLOCKSIZE:
printf("%u\n", block->data.stream_info.max_blocksize);
break;
case OP__SHOW_MIN_FRAMESIZE:
printf("%u\n", block->data.stream_info.min_framesize);
break;
case OP__SHOW_MAX_FRAMESIZE:
printf("%u\n", block->data.stream_info.max_framesize);
break;
case OP__SHOW_SAMPLE_RATE:
printf("%u\n", block->data.stream_info.sample_rate);
break;
case OP__SHOW_CHANNELS:
printf("%u\n", block->data.stream_info.channels);
break;
case OP__SHOW_BPS:
printf("%u\n", block->data.stream_info.bits_per_sample);
break;
case OP__SHOW_TOTAL_SAMPLES:
printf("%" PRIu64 "\n", block->data.stream_info.total_samples);
break;
case OP__SET_MD5SUM:
memcpy(block->data.stream_info.md5sum, operation->argument.streaminfo_md5.value, 16);
*needs_write = true;
break;
case OP__SET_MIN_BLOCKSIZE:
block->data.stream_info.min_blocksize = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_MAX_BLOCKSIZE:
block->data.stream_info.max_blocksize = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_MIN_FRAMESIZE:
block->data.stream_info.min_framesize = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_MAX_FRAMESIZE:
block->data.stream_info.max_framesize = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_SAMPLE_RATE:
block->data.stream_info.sample_rate = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_CHANNELS:
block->data.stream_info.channels = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_BPS:
block->data.stream_info.bits_per_sample = operation->argument.streaminfo_uint32.value;
*needs_write = true;
break;
case OP__SET_TOTAL_SAMPLES:
block->data.stream_info.total_samples = operation->argument.streaminfo_uint64.value;
*needs_write = true;
break;
default:
ok = false;
FLAC__ASSERT(0);
break;
};
FLAC__metadata_iterator_delete(iterator);
return ok;
}

View File

@ -0,0 +1,374 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "options.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "share/grabbag.h" /* for grabbag__file_get_filesize() */
#include "share/utf8.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "operations_shorthand.h"
#include "share/compat.h"
static FLAC__bool remove_vc_all(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write);
static FLAC__bool remove_vc_field(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write);
static FLAC__bool remove_vc_firstfield(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write);
static FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const Argument_VcField *field, FLAC__bool *needs_write, FLAC__bool raw);
static FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool *needs_write, FLAC__bool raw);
static FLAC__bool export_vc_to(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool raw);
FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw)
{
FLAC__bool ok = true, found_vc_block = false;
FLAC__StreamMetadata *block = 0;
FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
if(0 == iterator)
die("out of memory allocating iterator");
FLAC__metadata_iterator_init(iterator, chain);
do {
block = FLAC__metadata_iterator_get_block(iterator);
if(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
found_vc_block = true;
} while(!found_vc_block && FLAC__metadata_iterator_next(iterator));
if(!found_vc_block) {
/* create a new block if necessary */
if(operation->type == OP__SET_VC_FIELD || operation->type == OP__IMPORT_VC_FROM) {
block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
if(0 == block)
die("out of memory allocating VORBIS_COMMENT block");
while(FLAC__metadata_iterator_next(iterator))
;
if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) {
print_error_with_chain_status(chain, "%s: ERROR: adding new VORBIS_COMMENT block to metadata", filename);
return false;
}
/* iterator is left pointing to new block */
FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block);
}
else {
FLAC__metadata_iterator_delete(iterator);
return ok;
}
}
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
switch(operation->type) {
case OP__SHOW_VC_VENDOR:
write_vc_field(prefix_with_filename? filename : 0, &block->data.vorbis_comment.vendor_string, raw, stdout);
break;
case OP__SHOW_VC_FIELD:
write_vc_fields(prefix_with_filename? filename : 0, operation->argument.vc_field_name.value, block->data.vorbis_comment.comments, block->data.vorbis_comment.num_comments, raw, stdout);
break;
case OP__REMOVE_VC_ALL:
ok = remove_vc_all(filename, block, needs_write);
break;
case OP__REMOVE_VC_FIELD:
ok = remove_vc_field(filename, block, operation->argument.vc_field_name.value, needs_write);
break;
case OP__REMOVE_VC_FIRSTFIELD:
ok = remove_vc_firstfield(filename, block, operation->argument.vc_field_name.value, needs_write);
break;
case OP__SET_VC_FIELD:
#ifdef _WIN32 /* do not convert anything or things will break */
ok = set_vc_field(filename, block, &operation->argument.vc_field, needs_write, true);
#else
ok = set_vc_field(filename, block, &operation->argument.vc_field, needs_write, raw);
#endif
break;
case OP__IMPORT_VC_FROM:
ok = import_vc_from(filename, block, &operation->argument.filename, needs_write, raw);
break;
case OP__EXPORT_VC_TO:
ok = export_vc_to(filename, block, &operation->argument.filename, raw);
break;
default:
ok = false;
FLAC__ASSERT(0);
break;
};
FLAC__metadata_iterator_delete(iterator);
return ok;
}
/*
* local routines
*/
FLAC__bool remove_vc_all(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write)
{
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
FLAC__ASSERT(0 != needs_write);
if(0 != block->data.vorbis_comment.comments) {
FLAC__ASSERT(block->data.vorbis_comment.num_comments > 0);
if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, 0)) {
flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename);
return false;
}
*needs_write = true;
}
else {
FLAC__ASSERT(block->data.vorbis_comment.num_comments == 0);
}
return true;
}
FLAC__bool remove_vc_field(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write)
{
int n;
FLAC__ASSERT(0 != needs_write);
n = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, field_name);
if(n < 0) {
flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename);
return false;
}
else if(n > 0)
*needs_write = true;
return true;
}
FLAC__bool remove_vc_firstfield(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write)
{
int n;
FLAC__ASSERT(0 != needs_write);
n = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, field_name);
if(n < 0) {
flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename);
return false;
}
else if(n > 0)
*needs_write = true;
return true;
}
FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const Argument_VcField *field, FLAC__bool *needs_write, FLAC__bool raw)
{
FLAC__StreamMetadata_VorbisComment_Entry entry;
char *converted;
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
FLAC__ASSERT(0 != field);
FLAC__ASSERT(0 != needs_write);
if(field->field_value_from_file) {
/* read the file into 'data' */
FILE *f = 0;
char *data = 0;
const FLAC__off_t size = grabbag__file_get_filesize(field->field_value);
if(size < 0) {
flac_fprintf(stderr, "%s: ERROR: can't open file '%s' for '%s' tag value\n", filename, field->field_value, field->field_name);
return false;
}
if(size >= 0x100000) { /* magic arbitrary limit, actual format limit is near 16MB */
flac_fprintf(stderr, "%s: ERROR: file '%s' for '%s' tag value is too large\n", filename, field->field_value, field->field_name);
return false;
}
if(0 == (data = malloc(size+1)))
die("out of memory allocating tag value");
data[size] = '\0';
if(0 == (f = flac_fopen(field->field_value, "rb")) || fread(data, 1, size, f) != (size_t)size) {
flac_fprintf(stderr, "%s: ERROR: while reading file '%s' for '%s' tag value: %s\n", filename, field->field_value, field->field_name, strerror(errno));
free(data);
if(f)
fclose(f);
return false;
}
fclose(f);
if(strlen(data) != (size_t)size) {
free(data);
flac_fprintf(stderr, "%s: ERROR: file '%s' for '%s' tag value has embedded NULs\n", filename, field->field_value, field->field_name);
return false;
}
/* move 'data' into 'converted', converting to UTF-8 if necessary */
if(raw) {
converted = data;
}
else if(utf8_encode(data, &converted) >= 0) {
free(data);
}
else {
free(data);
flac_fprintf(stderr, "%s: ERROR: converting file '%s' contents to UTF-8 for tag value\n", filename, field->field_value);
return false;
}
/* create and entry and append it */
if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, field->field_name, converted)) {
free(converted);
flac_fprintf(stderr, "%s: ERROR: file '%s' for '%s' tag value is not valid UTF-8\n", filename, field->field_value, field->field_name);
return false;
}
free(converted);
if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) {
flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename);
return false;
}
*needs_write = true;
return true;
}
else {
FLAC__bool needs_free = false;
entry.entry = (FLAC__byte *)field->field;
if(raw) {
entry.entry = (FLAC__byte *)field->field;
}
else if(utf8_encode(field->field, &converted) >= 0) {
entry.entry = (FLAC__byte *)converted;
needs_free = true;
}
else {
flac_fprintf(stderr, "%s: ERROR: converting comment '%s' to UTF-8\n", filename, field->field);
return false;
}
entry.length = strlen((const char *)entry.entry);
if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) {
if(needs_free)
free(converted);
/*
* our previous parsing has already established that the field
* name is OK, so it must be the field value
*/
flac_fprintf(stderr, "%s: ERROR: tag value for '%s' is not valid UTF-8\n", filename, field->field_name);
return false;
}
if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
if(needs_free)
free(converted);
flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename);
return false;
}
*needs_write = true;
if(needs_free)
free(converted);
return true;
}
}
FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool *needs_write, FLAC__bool raw)
{
FILE *f;
char line[65536];
FLAC__bool ret;
if(0 == vc_filename->value || strlen(vc_filename->value) == 0) {
flac_fprintf(stderr, "%s: ERROR: empty import file name\n", filename);
return false;
}
if(0 == strcmp(vc_filename->value, "-"))
f = stdin;
else
f = flac_fopen(vc_filename->value, "r");
if(0 == f) {
flac_fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, vc_filename->value, strerror(errno));
return false;
}
ret = true;
while(ret && !feof(f) && fgets(line, sizeof(line), f) != NULL) {
if(!feof(f)) {
char *p = strchr(line, '\n');
if(0 == p) {
flac_fprintf(stderr, "%s: ERROR: line too long, aborting\n", vc_filename->value);
ret = false;
}
else {
const char *violation;
Argument_VcField field;
*p = '\0';
memset(&field, 0, sizeof(Argument_VcField));
field.field_value_from_file = false;
if(!parse_vorbis_comment_field(line, &field.field, &field.field_name, &field.field_value, &field.field_value_length, &violation)) {
FLAC__ASSERT(0 != violation);
flac_fprintf(stderr, "%s: ERROR: malformed vorbis comment field \"%s\",\n %s\n", vc_filename->value, line, violation);
ret = false;
}
else {
ret = set_vc_field(filename, block, &field, needs_write, raw);
}
if(0 != field.field)
free(field.field);
if(0 != field.field_name)
free(field.field_name);
if(0 != field.field_value)
free(field.field_value);
}
}
};
if(f != stdin)
fclose(f);
return ret;
}
FLAC__bool export_vc_to(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool raw)
{
FILE *f;
FLAC__bool ret;
if(0 == vc_filename->value || strlen(vc_filename->value) == 0) {
flac_fprintf(stderr, "%s: ERROR: empty export file name\n", filename);
return false;
}
if(0 == strcmp(vc_filename->value, "-"))
f = stdout;
else
f = flac_fopen(vc_filename->value, "w");
if(0 == f) {
flac_fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, vc_filename->value, strerror(errno));
return false;
}
ret = true;
write_vc_fields(0, 0, block->data.vorbis_comment.comments, block->data.vorbis_comment.num_comments, raw, f);
if(f != stdout)
fclose(f);
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,217 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef metaflac__options_h
#define metaflac__options_h
#include "FLAC/format.h"
#if 0
/*[JEC] was:#if HAVE_GETOPT_LONG*/
/*[JEC] see flac/include/share/getopt.h as to why the change */
# include <getopt.h>
#else
# include "share/getopt.h"
#endif
extern struct share__option long_options_[];
typedef enum {
OP__SHOW_MD5SUM,
OP__SHOW_MIN_BLOCKSIZE,
OP__SHOW_MAX_BLOCKSIZE,
OP__SHOW_MIN_FRAMESIZE,
OP__SHOW_MAX_FRAMESIZE,
OP__SHOW_SAMPLE_RATE,
OP__SHOW_CHANNELS,
OP__SHOW_BPS,
OP__SHOW_TOTAL_SAMPLES,
OP__SET_MD5SUM,
OP__SET_MIN_BLOCKSIZE,
OP__SET_MAX_BLOCKSIZE,
OP__SET_MIN_FRAMESIZE,
OP__SET_MAX_FRAMESIZE,
OP__SET_SAMPLE_RATE,
OP__SET_CHANNELS,
OP__SET_BPS,
OP__SET_TOTAL_SAMPLES,
OP__SHOW_VC_VENDOR,
OP__SHOW_VC_FIELD,
OP__REMOVE_VC_ALL,
OP__REMOVE_VC_FIELD,
OP__REMOVE_VC_FIRSTFIELD,
OP__SET_VC_FIELD,
OP__IMPORT_VC_FROM,
OP__EXPORT_VC_TO,
OP__IMPORT_CUESHEET_FROM,
OP__EXPORT_CUESHEET_TO,
OP__IMPORT_PICTURE_FROM,
OP__EXPORT_PICTURE_TO,
OP__ADD_SEEKPOINT,
OP__ADD_REPLAY_GAIN,
OP__SCAN_REPLAY_GAIN,
OP__ADD_PADDING,
OP__LIST,
OP__APPEND,
OP__REMOVE,
OP__REMOVE_ALL,
OP__MERGE_PADDING,
OP__SORT_PADDING
} OperationType;
typedef enum {
ARG__BLOCK_NUMBER,
ARG__BLOCK_TYPE,
ARG__EXCEPT_BLOCK_TYPE,
ARG__DATA_FORMAT,
ARG__FROM_FILE
} ArgumentType;
typedef struct {
FLAC__byte value[16];
} Argument_StreaminfoMD5;
typedef struct {
FLAC__uint32 value;
} Argument_StreaminfoUInt32;
typedef struct {
FLAC__uint64 value;
} Argument_StreaminfoUInt64;
typedef struct {
char *value;
} Argument_VcFieldName;
typedef struct {
char *field; /* the whole field as passed on the command line, i.e. "NAME=VALUE" */
char *field_name;
/* according to the vorbis spec, field values can contain \0 so simple C strings are not enough here */
unsigned field_value_length;
char *field_value;
FLAC__bool field_value_from_file; /* true if field_value holds a filename for the value, false for plain value */
} Argument_VcField;
typedef struct {
char *value;
} Argument_String;
typedef struct {
unsigned num_entries;
unsigned *entries;
} Argument_BlockNumber;
typedef struct {
FLAC__MetadataType type;
char application_id[4]; /* only relevant if type == FLAC__STREAM_METADATA_TYPE_APPLICATION */
FLAC__bool filter_application_by_id;
} Argument_BlockTypeEntry;
typedef struct {
unsigned num_entries;
Argument_BlockTypeEntry *entries;
} Argument_BlockType;
typedef struct {
FLAC__bool is_binary;
} Argument_DataFormat;
typedef struct {
char *file_name;
} Argument_FromFile;
typedef struct {
char *specification;
} Argument_AddSeekpoint;
typedef struct {
char *filename;
Argument_AddSeekpoint *add_seekpoint_link;
} Argument_ImportCuesheetFrom;
typedef struct {
char *filename;
const Argument_BlockNumber *block_number_link; /* may be NULL to mean 'first PICTURE block' */
} Argument_ExportPictureTo;
typedef struct {
unsigned length;
} Argument_AddPadding;
typedef struct {
OperationType type;
union {
Argument_StreaminfoMD5 streaminfo_md5;
Argument_StreaminfoUInt32 streaminfo_uint32;
Argument_StreaminfoUInt64 streaminfo_uint64;
Argument_VcFieldName vc_field_name;
Argument_VcField vc_field;
Argument_String filename;
Argument_String specification;
Argument_ImportCuesheetFrom import_cuesheet_from;
Argument_ExportPictureTo export_picture_to;
Argument_AddSeekpoint add_seekpoint;
Argument_AddPadding add_padding;
} argument;
} Operation;
typedef struct {
ArgumentType type;
union {
Argument_BlockNumber block_number;
Argument_BlockType block_type;
Argument_DataFormat data_format;
Argument_FromFile from_file;
} value;
} Argument;
typedef struct {
FLAC__bool preserve_modtime;
FLAC__bool prefix_with_filename;
FLAC__bool utf8_convert;
FLAC__bool use_padding;
FLAC__bool cued_seekpoints;
FLAC__bool show_long_help;
FLAC__bool show_version;
FLAC__bool application_data_format_is_hexdump;
struct {
Operation *operations;
unsigned num_operations;
unsigned capacity;
} ops;
struct {
struct {
unsigned num_shorthand_ops;
unsigned num_major_ops;
FLAC__bool has_block_type;
FLAC__bool has_except_block_type;
} checks;
Argument *arguments;
unsigned num_arguments;
unsigned capacity;
} args;
unsigned num_files;
char **filenames;
} CommandLineOptions;
void init_options(CommandLineOptions *options);
FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options);
void free_options(CommandLineOptions *options);
#endif

View File

@ -0,0 +1,330 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "usage.h"
#include "FLAC/format.h"
#include <stdarg.h>
#include <stdio.h>
#include "share/compat.h"
static void usage_header(FILE *out)
{
fprintf(out, "==============================================================================\n");
fprintf(out, "metaflac - Command-line FLAC metadata editor version %s\n", FLAC__VERSION_STRING);
fprintf(out, "Copyright (C) 2001-2009 Josh Coalson\n");
fprintf(out, "Copyright (C) 2011-2016 Xiph.Org Foundation\n");
fprintf(out, "\n");
fprintf(out, "This program is free software; you can redistribute it and/or\n");
fprintf(out, "modify it under the terms of the GNU General Public License\n");
fprintf(out, "as published by the Free Software Foundation; either version 2\n");
fprintf(out, "of the License, or (at your option) any later version.\n");
fprintf(out, "\n");
fprintf(out, "This program is distributed in the hope that it will be useful,\n");
fprintf(out, "but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
fprintf(out, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
fprintf(out, "GNU General Public License for more details.\n");
fprintf(out, "\n");
fprintf(out, "You should have received a copy of the GNU General Public License along\n");
fprintf(out, "with this program; if not, write to the Free Software Foundation, Inc.,\n");
fprintf(out, "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n");
fprintf(out, "==============================================================================\n");
}
static void usage_summary(FILE *out)
{
fprintf(out, "Usage:\n");
fprintf(out, " metaflac [options] [operations] FLACfile [FLACfile ...]\n");
fprintf(out, "\n");
fprintf(out, "Use metaflac to list, add, remove, or edit metadata in one or more FLAC files.\n");
fprintf(out, "You may perform one major operation, or many shorthand operations at a time.\n");
fprintf(out, "\n");
fprintf(out, "Options:\n");
fprintf(out, "--preserve-modtime Preserve the original modification time in spite of edits\n");
fprintf(out, "--with-filename Prefix each output line with the FLAC file name\n");
fprintf(out, " (the default if more than one FLAC file is specified)\n");
fprintf(out, "--no-filename Do not prefix each output line with the FLAC file name\n");
fprintf(out, " (the default if only one FLAC file is specified)\n");
fprintf(out, "--no-utf8-convert Do not convert tags from UTF-8 to local charset,\n");
fprintf(out, " or vice versa. This is useful for scripts, and setting\n");
fprintf(out, " tags in situations where the locale is wrong.\n");
fprintf(out, "--dont-use-padding By default metaflac tries to use padding where possible\n");
fprintf(out, " to avoid rewriting the entire file if the metadata size\n");
fprintf(out, " changes. Use this option to tell metaflac to not take\n");
fprintf(out, " advantage of padding this way.\n");
}
int short_usage(const char *message, ...)
{
va_list args;
if(message) {
va_start(args, message);
(void) vfprintf(stderr, message, args);
va_end(args);
}
usage_header(stderr);
flac_fprintf(stderr, "\n");
flac_fprintf(stderr, "This is the short help; for full help use 'metaflac --help'\n");
flac_fprintf(stderr, "\n");
usage_summary(stderr);
return message? 1 : 0;
}
int long_usage(const char *message, ...)
{
FILE *out = (message? stderr : stdout);
va_list args;
if(message) {
va_start(args, message);
(void) vfprintf(stderr, message, args);
va_end(args);
}
usage_header(out);
fprintf(out, "\n");
usage_summary(out);
fprintf(out, "\n");
fprintf(out, "Shorthand operations:\n");
fprintf(out, "--show-md5sum Show the MD5 signature from the STREAMINFO block.\n");
fprintf(out, "--show-min-blocksize Show the minimum block size from the STREAMINFO block.\n");
fprintf(out, "--show-max-blocksize Show the maximum block size from the STREAMINFO block.\n");
fprintf(out, "--show-min-framesize Show the minimum frame size from the STREAMINFO block.\n");
fprintf(out, "--show-max-framesize Show the maximum frame size from the STREAMINFO block.\n");
fprintf(out, "--show-sample-rate Show the sample rate from the STREAMINFO block.\n");
fprintf(out, "--show-channels Show the number of channels from the STREAMINFO block.\n");
fprintf(out, "--show-bps Show the # of bits per sample from the STREAMINFO block.\n");
fprintf(out, "--show-total-samples Show the total # of samples from the STREAMINFO block.\n");
fprintf(out, "\n");
fprintf(out, "--show-vendor-tag Show the vendor string from the VORBIS_COMMENT block.\n");
fprintf(out, "--show-tag=NAME Show all tags where the field name matches 'NAME'.\n");
fprintf(out, "--remove-tag=NAME Remove all tags whose field name is 'NAME'.\n");
fprintf(out, "--remove-first-tag=NAME Remove first tag whose field name is 'NAME'.\n");
fprintf(out, "--remove-all-tags Remove all tags, leaving only the vendor string.\n");
fprintf(out, "--set-tag=FIELD Add a tag. The FIELD must comply with the Vorbis comment\n");
fprintf(out, " spec, of the form \"NAME=VALUE\". If there is currently\n");
fprintf(out, " no tag block, one will be created.\n");
fprintf(out, "--set-tag-from-file=FIELD Like --set-tag, except the VALUE is a filename\n");
fprintf(out, " whose contents will be read verbatim to set the tag value.\n");
fprintf(out, " Unless --no-utf8-convert is specified, the contents will\n");
fprintf(out, " be converted to UTF-8 from the local charset. This can\n");
fprintf(out, " be used to store a cuesheet in a tag (e.g.\n");
fprintf(out, " --set-tag-from-file=\"CUESHEET=image.cue\"). Do not try\n");
fprintf(out, " to store binary data in tag fields! Use APPLICATION\n");
fprintf(out, " blocks for that.\n");
fprintf(out, "--import-tags-from=FILE Import tags from a file. Use '-' for stdin. Each line\n");
fprintf(out, " should be of the form NAME=VALUE. Multi-line comments\n");
fprintf(out, " are currently not supported. Specify --remove-all-tags\n");
fprintf(out, " and/or --no-utf8-convert before --import-tags-from if\n");
fprintf(out, " necessary. If FILE is '-' (stdin), only one FLAC file\n");
fprintf(out, " may be specified.\n");
fprintf(out, "--export-tags-to=FILE Export tags to a file. Use '-' for stdout. Each line\n");
fprintf(out, " will be of the form NAME=VALUE. Specify\n");
fprintf(out, " --no-utf8-convert if necessary.\n");
fprintf(out, "--import-cuesheet-from=FILE Import a cuesheet from a file. Use '-' for stdin.\n");
fprintf(out, " Only one FLAC file may be specified. A seekpoint will be\n");
fprintf(out, " added for each index point in the cuesheet to the\n");
fprintf(out, " SEEKTABLE unless --no-cued-seekpoints is specified.\n");
fprintf(out, "--export-cuesheet-to=FILE Export CUESHEET block to a cuesheet file, suitable\n");
fprintf(out, " for use by CD authoring software. Use '-' for stdout.\n");
fprintf(out, " Only one FLAC file may be specified on the command line.\n");
fprintf(out, "--import-picture-from=FILENAME|SPECIFICATION Import a picture and store it in a\n");
fprintf(out, " PICTURE block. Either a filename for the picture file or\n");
fprintf(out, " a more complete specification form can be used. The\n");
fprintf(out, " SPECIFICATION is a string whose parts are separated by |\n");
fprintf(out, " characters. Some parts may be left empty to invoke\n");
fprintf(out, " default values. FILENAME is just shorthand for\n");
fprintf(out, " \"||||FILENAME\". The format of SPECIFICATION is:\n");
fprintf(out, " [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n");
fprintf(out, " TYPE is optional; it is a number from one of:\n");
fprintf(out, " 0: Other\n");
fprintf(out, " 1: 32x32 pixels 'file icon' (PNG only)\n");
fprintf(out, " 2: Other file icon\n");
fprintf(out, " 3: Cover (front)\n");
fprintf(out, " 4: Cover (back)\n");
fprintf(out, " 5: Leaflet page\n");
fprintf(out, " 6: Media (e.g. label side of CD)\n");
fprintf(out, " 7: Lead artist/lead performer/soloist\n");
fprintf(out, " 8: Artist/performer\n");
fprintf(out, " 9: Conductor\n");
fprintf(out, " 10: Band/Orchestra\n");
fprintf(out, " 11: Composer\n");
fprintf(out, " 12: Lyricist/text writer\n");
fprintf(out, " 13: Recording Location\n");
fprintf(out, " 14: During recording\n");
fprintf(out, " 15: During performance\n");
fprintf(out, " 16: Movie/video screen capture\n");
fprintf(out, " 17: A bright coloured fish\n");
fprintf(out, " 18: Illustration\n");
fprintf(out, " 19: Band/artist logotype\n");
fprintf(out, " 20: Publisher/Studio logotype\n");
fprintf(out, " The default is 3 (front cover). There may only be one picture each\n");
fprintf(out, " of type 1 and 2 in a file.\n");
fprintf(out, " MIME-TYPE is optional; if left blank, it will be detected from the\n");
fprintf(out, " file. For best compatibility with players, use pictures with MIME\n");
fprintf(out, " type image/jpeg or image/png. The MIME type can also be --> to\n");
fprintf(out, " mean that FILE is actually a URL to an image, though this use is\n");
fprintf(out, " discouraged.\n");
fprintf(out, " DESCRIPTION is optional; the default is an empty string\n");
fprintf(out, " The next part specfies the resolution and color information. If\n");
fprintf(out, " the MIME-TYPE is image/jpeg, image/png, or image/gif, you can\n");
fprintf(out, " usually leave this empty and they can be detected from the file.\n");
fprintf(out, " Otherwise, you must specify the width in pixels, height in pixels,\n");
fprintf(out, " and color depth in bits-per-pixel. If the image has indexed colors\n");
fprintf(out, " you should also specify the number of colors used.\n");
fprintf(out, " FILE is the path to the picture file to be imported, or the URL if\n");
fprintf(out, " MIME type is -->\n");
fprintf(out, "--export-picture-to=FILE Export PICTURE block to a file. Use '-' for stdout.\n");
fprintf(out, " Only one FLAC file may be specified. The first PICTURE\n");
fprintf(out, " block will be exported unless --export-picture-to is\n");
fprintf(out, " preceded by a --block-number=# option to specify the exact\n");
fprintf(out, " metadata block to extract. Note that the block number is\n");
fprintf(out, " the one shown by --list.\n");
fprintf(out, "--add-replay-gain Calculates the title and album gains/peaks of the given\n");
fprintf(out, " FLAC files as if all the files were part of one album,\n");
fprintf(out, " then stores them in the VORBIS_COMMENT block. The tags\n");
fprintf(out, " are the same as those used by vorbisgain. Existing\n");
fprintf(out, " ReplayGain tags will be replaced. If only one FLAC file\n");
fprintf(out, " is given, the album and title gains will be the same.\n");
fprintf(out, " Since this operation requires two passes, it is always\n");
fprintf(out, " executed last, after all other operations have been\n");
fprintf(out, " completed and written to disk. All FLAC files specified\n");
fprintf(out, " must have the same resolution, sample rate, and number\n");
fprintf(out, " of channels. The sample rate must be one of 8, 11.025,\n");
fprintf(out, " 12, 16, 22.05, 24, 32, 44.1, or 48 kHz.\n");
fprintf(out, "--scan-replay-gain Like --add-replay-gain, but only analyzes the files\n");
fprintf(out, " rather than writing them to tags.\n");
fprintf(out, "--remove-replay-gain Removes the ReplayGain tags.\n");
fprintf(out, "--add-seekpoint={#|X|#x|#s} Add seek points to a SEEKTABLE block\n");
fprintf(out, " # : a specific sample number for a seek point\n");
fprintf(out, " X : a placeholder point (always goes at the end of the SEEKTABLE)\n");
fprintf(out, " #x : # evenly spaced seekpoints, the first being at sample 0\n");
fprintf(out, " #s : a seekpoint every # seconds; # does not have to be a whole number\n");
fprintf(out, " If no SEEKTABLE block exists, one will be created. If\n");
fprintf(out, " one already exists, points will be added to the existing\n");
fprintf(out, " table, and any duplicates will be turned into placeholder\n");
fprintf(out, " points. You may use many --add-seekpoint options; the\n");
fprintf(out, " resulting SEEKTABLE will be the unique-ified union of\n");
fprintf(out, " all such values. Example: --add-seekpoint=100x\n");
fprintf(out, " --add-seekpoint=3.5s will add 100 evenly spaced\n");
fprintf(out, " seekpoints and a seekpoint every 3.5 seconds.\n");
fprintf(out, "--add-padding=length Add a padding block of the given length (in bytes).\n");
fprintf(out, " The overall length of the new block will be 4 + length;\n");
fprintf(out, " the extra 4 bytes is for the metadata block header.\n");
fprintf(out, "\n");
fprintf(out, "Major operations:\n");
fprintf(out, "--version\n");
fprintf(out, " Show the metaflac version number.\n");
fprintf(out, "--list\n");
fprintf(out, " List the contents of one or more metadata blocks to stdout. By default,\n");
fprintf(out, " all metadata blocks are listed in text format. Use the following options\n");
fprintf(out, " to change this behavior:\n");
fprintf(out, "\n");
fprintf(out, " --block-number=#[,#[...]]\n");
fprintf(out, " An optional comma-separated list of block numbers to display. The first\n");
fprintf(out, " block, the STREAMINFO block, is block 0.\n");
fprintf(out, "\n");
fprintf(out, " --block-type=type[,type[...]]\n");
fprintf(out, " --except-block-type=type[,type[...]]\n");
fprintf(out, " An optional comma-separated list of block types to be included or ignored\n");
fprintf(out, " with this option. Use only one of --block-type or --except-block-type.\n");
fprintf(out, " The valid block types are: STREAMINFO, PADDING, APPLICATION, SEEKTABLE,\n");
fprintf(out, " VORBIS_COMMENT. You may narrow down the types of APPLICATION blocks\n");
fprintf(out, " displayed as follows:\n");
fprintf(out, " APPLICATION:abcd The APPLICATION block(s) whose textual repre-\n");
fprintf(out, " sentation of the 4-byte ID is \"abcd\"\n");
fprintf(out, " APPLICATION:0xXXXXXXXX The APPLICATION block(s) whose hexadecimal big-\n");
fprintf(out, " endian representation of the 4-byte ID is\n");
fprintf(out, " \"0xXXXXXXXX\". For the example \"abcd\" above the\n");
fprintf(out, " hexadecimal equivalalent is 0x61626364\n");
fprintf(out, "\n");
fprintf(out, " NOTE: if both --block-number and --[except-]block-type are specified,\n");
fprintf(out, " the result is the logical AND of both arguments.\n");
fprintf(out, "\n");
#if 0
/*@@@ not implemented yet */
fprintf(out, " --data-format=binary|text\n");
fprintf(out, " By default a human-readable text representation of the data is displayed.\n");
fprintf(out, " You may specify --data-format=binary to dump the raw binary form of each\n");
fprintf(out, " metadata block. The output can be read in using a subsequent call to\n");
fprintf(out, " "metaflac --append --from-file=..."\n");
fprintf(out, "\n");
#endif
fprintf(out, " --application-data-format=hexdump|text\n");
fprintf(out, " If the application block you are displaying contains binary data but your\n");
fprintf(out, " --data-format=text, you can display a hex dump of the application data\n");
fprintf(out, " contents instead using --application-data-format=hexdump\n");
fprintf(out, "\n");
#if 0
/*@@@ not implemented yet */
fprintf(out, "--append\n");
fprintf(out, " Insert a metadata block from a file. The input file must be in the same\n");
fprintf(out, " format as generated with --list.\n");
fprintf(out, "\n");
fprintf(out, " --block-number=#\n");
fprintf(out, " Specify the insertion point (defaults to last block). The new block will\n");
fprintf(out, " be added after the given block number. This prevents the illegal insertion\n");
fprintf(out, " of a block before the first STREAMINFO block. You may not --append another\n");
fprintf(out, " STREAMINFO block.\n");
fprintf(out, "\n");
fprintf(out, " --from-file=filename\n");
fprintf(out, " Mandatory 'option' to specify the input file containing the block contents.\n");
fprintf(out, "\n");
fprintf(out, " --data-format=binary|text\n");
fprintf(out, " By default the block contents are assumed to be in binary format. You can\n");
fprintf(out, " override this by specifying --data-format=text\n");
fprintf(out, "\n");
#endif
fprintf(out, "--remove\n");
fprintf(out, " Remove one or more metadata blocks from the metadata. Unless\n");
fprintf(out, " --dont-use-padding is specified, the blocks will be replaced with padding.\n");
fprintf(out, " You may not remove the STREAMINFO block.\n");
fprintf(out, "\n");
fprintf(out, " --block-number=#[,#[...]]\n");
fprintf(out, " --block-type=type[,type[...]]\n");
fprintf(out, " --except-block-type=type[,type[...]]\n");
fprintf(out, " See --list above for usage.\n");
fprintf(out, "\n");
fprintf(out, " NOTE: if both --block-number and --[except-]block-type are specified,\n");
fprintf(out, " the result is the logical AND of both arguments.\n");
fprintf(out, "\n");
fprintf(out, "--remove-all\n");
fprintf(out, " Remove all metadata blocks (except the STREAMINFO block) from the\n");
fprintf(out, " metadata. Unless --dont-use-padding is specified, the blocks will be\n");
fprintf(out, " replaced with padding.\n");
fprintf(out, "\n");
fprintf(out, "--merge-padding\n");
fprintf(out, " Merge adjacent PADDING blocks into single blocks.\n");
fprintf(out, "\n");
fprintf(out, "--sort-padding\n");
fprintf(out, " Move all PADDING blocks to the end of the metadata and merge them into a\n");
fprintf(out, " single block.\n");
return message? 1 : 0;
}

View File

@ -0,0 +1,26 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef metaflac__usage_h
#define metaflac__usage_h
int short_usage(const char *message, ...);
int long_usage(const char *message, ...);
#endif

View File

@ -0,0 +1,275 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils.h"
#include "FLAC/assert.h"
#include "share/alloc.h"
#include "share/safe_str.h"
#include "share/utf8.h"
#include "share/compat.h"
void die(const char *message)
{
FLAC__ASSERT(0 != message);
flac_fprintf(stderr, "ERROR: %s\n", message);
exit(1);
}
#ifdef FLAC__VALGRIND_TESTING
size_t local_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t ret = fwrite(ptr, size, nmemb, stream);
if(!ferror(stream))
fflush(stream);
return ret;
}
#endif
char *local_strdup(const char *source)
{
char *ret;
FLAC__ASSERT(0 != source);
if(0 == (ret = strdup(source)))
die("out of memory during strdup()");
return ret;
}
void local_strcat(char **dest, const char *source)
{
size_t ndest, nsource;
FLAC__ASSERT(0 != dest);
FLAC__ASSERT(0 != source);
ndest = *dest? strlen(*dest) : 0;
nsource = strlen(source);
if(nsource == 0)
return;
*dest = safe_realloc_add_3op_(*dest, ndest, /*+*/nsource, /*+*/1);
if(0 == *dest)
die("out of memory growing string");
safe_strncpy((*dest)+ndest, source, nsource + 1);
}
static inline int local_isprint(int c)
{
if (c < 32) return 0;
return isprint(c);
}
void hexdump(const char *filename, const FLAC__byte *buf, unsigned bytes, const char *indent)
{
unsigned i, left = bytes;
const FLAC__byte *b = buf;
for(i = 0; i < bytes; i += 16) {
flac_printf("%s%s", filename? filename:"", filename? ":":"");
printf("%s%08X: "
"%02X %02X %02X %02X %02X %02X %02X %02X "
"%02X %02X %02X %02X %02X %02X %02X %02X "
"%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
indent, i,
left > 0? (unsigned char)b[ 0] : 0,
left > 1? (unsigned char)b[ 1] : 0,
left > 2? (unsigned char)b[ 2] : 0,
left > 3? (unsigned char)b[ 3] : 0,
left > 4? (unsigned char)b[ 4] : 0,
left > 5? (unsigned char)b[ 5] : 0,
left > 6? (unsigned char)b[ 6] : 0,
left > 7? (unsigned char)b[ 7] : 0,
left > 8? (unsigned char)b[ 8] : 0,
left > 9? (unsigned char)b[ 9] : 0,
left > 10? (unsigned char)b[10] : 0,
left > 11? (unsigned char)b[11] : 0,
left > 12? (unsigned char)b[12] : 0,
left > 13? (unsigned char)b[13] : 0,
left > 14? (unsigned char)b[14] : 0,
left > 15? (unsigned char)b[15] : 0,
(left > 0) ? (local_isprint(b[ 0]) ? b[ 0] : '.') : ' ',
(left > 1) ? (local_isprint(b[ 1]) ? b[ 1] : '.') : ' ',
(left > 2) ? (local_isprint(b[ 2]) ? b[ 2] : '.') : ' ',
(left > 3) ? (local_isprint(b[ 3]) ? b[ 3] : '.') : ' ',
(left > 4) ? (local_isprint(b[ 4]) ? b[ 4] : '.') : ' ',
(left > 5) ? (local_isprint(b[ 5]) ? b[ 5] : '.') : ' ',
(left > 6) ? (local_isprint(b[ 6]) ? b[ 6] : '.') : ' ',
(left > 7) ? (local_isprint(b[ 7]) ? b[ 7] : '.') : ' ',
(left > 8) ? (local_isprint(b[ 8]) ? b[ 8] : '.') : ' ',
(left > 9) ? (local_isprint(b[ 9]) ? b[ 9] : '.') : ' ',
(left > 10) ? (local_isprint(b[10]) ? b[10] : '.') : ' ',
(left > 11) ? (local_isprint(b[11]) ? b[11] : '.') : ' ',
(left > 12) ? (local_isprint(b[12]) ? b[12] : '.') : ' ',
(left > 13) ? (local_isprint(b[13]) ? b[13] : '.') : ' ',
(left > 14) ? (local_isprint(b[14]) ? b[14] : '.') : ' ',
(left > 15) ? (local_isprint(b[15]) ? b[15] : '.') : ' '
);
left -= 16;
b += 16;
}
}
void print_error_with_chain_status(FLAC__Metadata_Chain *chain, const char *format, ...)
{
const FLAC__Metadata_ChainStatus status = FLAC__metadata_chain_status(chain);
va_list args;
FLAC__ASSERT(0 != format);
va_start(args, format);
(void) flac_vfprintf(stderr, format, args);
va_end(args);
flac_fprintf(stderr, ", status = \"%s\"\n", FLAC__Metadata_ChainStatusString[status]);
if(status == FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE) {
flac_fprintf(stderr, "\n"
"The FLAC file could not be opened. Most likely the file does not exist\n"
"or is not readable.\n"
);
}
else if(status == FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE) {
flac_fprintf(stderr, "\n"
"The file does not appear to be a FLAC file.\n"
);
}
else if(status == FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE) {
flac_fprintf(stderr, "\n"
"The FLAC file does not have write permissions.\n"
);
}
else if(status == FLAC__METADATA_CHAIN_STATUS_BAD_METADATA) {
flac_fprintf(stderr, "\n"
"The metadata to be written does not conform to the FLAC metadata\n"
"specifications.\n"
);
}
else if(status == FLAC__METADATA_CHAIN_STATUS_READ_ERROR) {
flac_fprintf(stderr, "\n"
"There was an error while reading the FLAC file.\n"
);
}
else if(status == FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR) {
flac_fprintf(stderr, "\n"
"There was an error while writing FLAC file; most probably the disk is\n"
"full.\n"
);
}
else if(status == FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR) {
flac_fprintf(stderr, "\n"
"There was an error removing the temporary FLAC file.\n"
);
}
}
FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation)
{
static const char * const violations[] = {
"field name contains invalid character",
"field contains no '=' character"
};
char *p, *q, *s;
if(0 != field)
*field = local_strdup(field_ref);
s = local_strdup(field_ref);
if(0 == (p = strchr(s, '='))) {
free(s);
*violation = violations[1];
return false;
}
*p++ = '\0';
for(q = s; *q; q++) {
if(*q < 0x20 || *q > 0x7d || *q == 0x3d) {
free(s);
*violation = violations[0];
return false;
}
}
*name = local_strdup(s);
*value = local_strdup(p);
*length = strlen(p);
free(s);
return true;
}
void write_vc_field(const char *filename, const FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__bool raw, FILE *f)
{
if(0 != entry->entry) {
if(filename)
flac_fprintf(f, "%s:", filename);
if(!raw) {
/*
* WATCHOUT: comments that contain an embedded null will
* be truncated by utf_decode().
*/
#ifdef _WIN32 /* if we are outputting to console, we need to use proper print functions to show unicode characters */
if (f == stdout || f == stderr) {
flac_fprintf(f, "%s", entry->entry);
} else {
#endif
char *converted;
if(utf8_decode((const char *)entry->entry, &converted) >= 0) {
(void) local_fwrite(converted, 1, strlen(converted), f);
free(converted);
}
else {
(void) local_fwrite(entry->entry, 1, entry->length, f);
}
#ifdef _WIN32
}
#endif
}
else {
(void) local_fwrite(entry->entry, 1, entry->length, f);
}
}
putc('\n', f);
}
void write_vc_fields(const char *filename, const char *field_name, const FLAC__StreamMetadata_VorbisComment_Entry entry[], unsigned num_entries, FLAC__bool raw, FILE *f)
{
unsigned i;
const unsigned field_name_length = (0 != field_name)? strlen(field_name) : 0;
for(i = 0; i < num_entries; i++) {
if(0 == field_name || FLAC__metadata_object_vorbiscomment_entry_matches(entry[i], field_name, field_name_length))
write_vc_field(filename, entry + i, raw, f);
}
}

View File

@ -0,0 +1,42 @@
/* metaflac - Command-line FLAC metadata editor
* Copyright (C) 2001-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef metaflac__utils_h
#define metaflac__utils_h
#include "FLAC/metadata.h"
#include <stdio.h> /* for FILE */
void die(const char *message);
#ifdef FLAC__VALGRIND_TESTING
size_t local_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
#else
#define local_fwrite fwrite
#endif
char *local_strdup(const char *source);
void local_strcat(char **dest, const char *source);
void hexdump(const char *filename, const FLAC__byte *buf, unsigned bytes, const char *indent);
void print_error_with_chain_status(FLAC__Metadata_Chain *chain, const char *format, ...);
FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation);
void write_vc_field(const char *filename, const FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__bool raw, FILE *f);
void write_vc_fields(const char *filename, const char *field_name, const FLAC__StreamMetadata_VorbisComment_Entry entry[], unsigned num_entries, FLAC__bool raw, FILE *f);
#endif