1 /* EasyTAG - tag editor for audio files 2 * Copyright (C) 2014 David King <amigadave@amigadave.com> 3 * Copyright (C) 1999, 2000 Scott Thomas Haug 4 * Copyright (C) 2002 Thijmen Klok (thijmen@id3lib.org) 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the Free 8 * Software Foundation; either version 2 of the License, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 * more details. 15 * 16 * You should have received a copy of the GNU General Public License along with 17 * this program; if not, write to the Free Software Foundation, Inc., 51 18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21 #include "config.h" 22 23 #ifdef ENABLE_ID3LIB 24 25 #include <id3.h> 26 #include <id3/field.h> 27 #include <id3/tag.h> 28 29 #include "id3_bugfix.h" 30 31 #ifdef __cplusplus 32 extern "C" 33 { 34 #endif /* __cplusplus */ 35 36 #define ID3_CATCH(code) try { code; } catch (...) { } 37 38 // 39 // Tag wrappers 40 // 41 42 ID3_C_EXPORT bool CCONV ID3Field_SetEncoding(ID3Field * field,ID3_TextEnc enc)43 ID3Field_SetEncoding(ID3Field *field, ID3_TextEnc enc) 44 { 45 bool changed = false; 46 if (field) 47 { 48 ID3_CATCH(changed = reinterpret_cast<ID3_Field *>(field)->SetEncoding(enc)); 49 } 50 return changed; 51 } 52 53 ID3_C_EXPORT ID3_TextEnc CCONV ID3Field_GetEncoding(const ID3Field * field)54 ID3Field_GetEncoding(const ID3Field *field) 55 { 56 ID3_TextEnc enc = ID3TE_NONE; 57 if (field) 58 { 59 ID3_CATCH(enc = reinterpret_cast<const ID3_Field *>(field)->GetEncoding()); 60 } 61 return enc; 62 } 63 64 ID3_C_EXPORT bool CCONV ID3Field_IsEncodable(const ID3Field * field)65 ID3Field_IsEncodable(const ID3Field *field) 66 { 67 bool isEncodable = false; 68 if (field) 69 { 70 ID3_CATCH(isEncodable = reinterpret_cast<const ID3_Field *>(field)->IsEncodable()); 71 } 72 return isEncodable; 73 } 74 75 ID3_C_EXPORT ID3_FieldType CCONV ID3Field_GetType(const ID3Field * field)76 ID3Field_GetType(const ID3Field *field) 77 { 78 ID3_FieldType fieldType = ID3FTY_NONE; 79 if (field) 80 { 81 ID3_CATCH(fieldType = reinterpret_cast<const ID3_Field *>(field)->GetType()); 82 } 83 return fieldType; 84 } 85 86 /*ID3_C_EXPORT ID3_FieldID CCONV 87 ID3Field_GetID(const ID3Field *field) 88 { 89 ID3_FieldID fieldID = ID3FN_NOFIELD; 90 if (field) 91 { 92 ID3_CATCH(fieldType = reinterpret_cast<const ID3_Field *>(field)->GetID()); 93 } 94 return fieldType; 95 }*/ 96 97 98 99 // 100 // Header wrappers 101 // 102 103 // Call with : 104 // const Mp3_Headerinfo* headerInfo = ID3Tag_GetMp3HeaderInfo(tag); 105 ID3_C_EXPORT const Mp3_Headerinfo* CCONV ID3Tag_GetMp3HeaderInfo(ID3Tag * tag)106 ID3Tag_GetMp3HeaderInfo(ID3Tag *tag) 107 { 108 const Mp3_Headerinfo* headerInfo = NULL; 109 if (tag) 110 { 111 ID3_CATCH(headerInfo = reinterpret_cast<const ID3_Tag *>(tag)->GetMp3HeaderInfo()); 112 } 113 return headerInfo; 114 } 115 116 // Call with : 117 // Mp3_Headerinfo* headerInfo = malloc(sizeof(Mp3_Headerinfo)); 118 // ID3Tag_GetMp3HeaderInfo(tag, headerInfo); 119 /*ID3_C_EXPORT bool CCONV 120 ID3Tag_GetMp3HeaderInfo(ID3Tag *tag, Mp3_Headerinfo* headerInfo) 121 { 122 const Mp3_Headerinfo* rem_headerInfo = NULL; 123 if (tag) 124 { 125 ID3_CATCH(rem_headerInfo = reinterpret_cast<const ID3_Tag * >(tag)->GetMp3HeaderInfo()); 126 } 127 // Does GCC understand this? (VS does) 128 if (rem_headerInfo) *headerInfo=*rem_headerInfo; 129 return rem_headerInfo!=NULL; 130 }*/ 131 132 133 #ifdef __cplusplus 134 } 135 #endif /* __cplusplus */ 136 137 #endif /* ENABLE_ID3LIB */ 138