1*600f14f4SXin Li /* metaflac - Command-line FLAC metadata editor 2*600f14f4SXin Li * Copyright (C) 2001-2009 Josh Coalson 3*600f14f4SXin Li * Copyright (C) 2011-2023 Xiph.Org Foundation 4*600f14f4SXin Li * 5*600f14f4SXin Li * This program is free software; you can redistribute it and/or 6*600f14f4SXin Li * modify it under the terms of the GNU General Public License 7*600f14f4SXin Li * as published by the Free Software Foundation; either version 2 8*600f14f4SXin Li * of the License, or (at your option) any later version. 9*600f14f4SXin Li * 10*600f14f4SXin Li * This program is distributed in the hope that it will be useful, 11*600f14f4SXin Li * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*600f14f4SXin Li * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*600f14f4SXin Li * GNU General Public License for more details. 14*600f14f4SXin Li * 15*600f14f4SXin Li * You should have received a copy of the GNU General Public License along 16*600f14f4SXin Li * with this program; if not, write to the Free Software Foundation, Inc., 17*600f14f4SXin Li * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18*600f14f4SXin Li */ 19*600f14f4SXin Li 20*600f14f4SXin Li #ifndef metaflac__utils_h 21*600f14f4SXin Li #define metaflac__utils_h 22*600f14f4SXin Li 23*600f14f4SXin Li #include "FLAC/metadata.h" 24*600f14f4SXin Li #include <stdio.h> /* for FILE */ 25*600f14f4SXin Li 26*600f14f4SXin Li #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 27*600f14f4SXin Li #undef stderr 28*600f14f4SXin Li #define stderr stdout 29*600f14f4SXin Li #endif 30*600f14f4SXin Li 31*600f14f4SXin Li void die(const char *message); 32*600f14f4SXin Li #ifdef FLAC__VALGRIND_TESTING 33*600f14f4SXin Li size_t local_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); 34*600f14f4SXin Li #else 35*600f14f4SXin Li #define local_fwrite fwrite 36*600f14f4SXin Li #endif 37*600f14f4SXin Li char *local_strdup(const char *source); 38*600f14f4SXin Li void local_strcat(char **dest, const char *source); 39*600f14f4SXin Li void hexdump(const char *filename, const FLAC__byte *buf, unsigned bytes, const char *indent); 40*600f14f4SXin Li void print_error_with_chain_status(FLAC__Metadata_Chain *chain, const char *format, ...); 41*600f14f4SXin Li 42*600f14f4SXin Li FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation); 43*600f14f4SXin Li 44*600f14f4SXin Li void write_vc_field(const char *filename, const FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__bool raw, FILE *f); 45*600f14f4SXin Li 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); 46*600f14f4SXin Li 47*600f14f4SXin Li #endif 48