1 /* EasyTAG - tag editor for audio files 2 * Copyright (C) 2014 David King <amigadave@amigadave.com> 3 * Copyright (C) 2002 Artur Polaczynski (Ar't) <artii@o2.pl> 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License as published by the Free 7 * Software Foundation; either version 2 of the License, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 * 15 * You should have received a copy of the GNU General Public License along with 16 * this program; if not, write to the Free Software Foundation, Inc., 51 17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef _APETAGLIB_H 21 #define _APETAGLIB_H 22 23 /** \file 24 \brief All function related to apetag 25 */ 26 27 // Uncomment this line to enable debug messages 28 //#define APE_TAG_DEBUG 29 30 #ifdef __WATCOMC__ // Watcom don't like || in ifdef and use #if define() || define() 31 #define USE_CHSIZE 32 #define strcasecmp(a,b) stricmp(a,b) 33 #define index(a,b) strchr(a,b) 34 #endif 35 36 /**\{*/ 37 #ifdef APE_TAG_DEBUG 38 #define PRINT_D(x) fprintf( stdout, x ) 39 #define PRINT_D1(x,a) fprintf( stdout, x, a ) 40 #define PRINT_D2(x,a,b) fprintf( stdout, x, a,b) 41 #define PRINT_D3(x,a,b,c) fprintf( stdout, x, a,b,c) 42 #define PRINT_D4(x,a,b,c,d) fprintf( stdout, x, a,b,c,d) 43 #define PRINT_D5(x,a,b,c,d,e) fprintf( stdout, x, a,b,c,d,e) 44 #define PRINT_D6(x,a,b,c,d,e,f) fprintf( stdout, x, a,b,c,d,e,f) 45 #define PRINT_D7(x,a,b,c,d,e,f,g) fprintf( stdout, x, a,b,c,d,e,f,g) 46 #define PRINT_D8(x,a,b,c,d,e,f,g,i) fprintf( stdout, x, a,b,c,d,e,f,g,i) 47 #define PRINT_D9(x,a,b,c,d,e,f,g,i,j) fprintf( stdout, x ,a,b,c,d,e,f,g,i,j ) 48 #else 49 #define PRINT_D(x) 50 #define PRINT_D1(x,a) 51 #define PRINT_D2(x,a,b) 52 #define PRINT_D3(x,a,b,c) 53 #define PRINT_D4(x,a,b,c,d) 54 #define PRINT_D5(x,a,b,c,d,e) 55 #define PRINT_D6(x,a,b,c,d,e,f) 56 #define PRINT_D7(x,a,b,c,d,e,f,g) 57 #define PRINT_D8(x,a,b,c,d,e,f,g,i) 58 #define PRINT_D9(x,a,b,c,d,e,f,g,i,j) 59 #endif /*APE_TAG_DEBUG*/ 60 61 #define PRINT_ERR(x) fprintf( stderr, x ) 62 #define PRINT_ERR1(x, a) fprintf( stderr, x ,a) 63 /**\}*/ 64 65 /** version of apetaglib defined in one place */ 66 #define APETAGLIB_VERSION "0.5pre1" 67 68 69 /*from winamp mpc plugin*/ 70 /** \name frame names */ 71 /**\{*/ 72 #define APE_TAG_FIELD_TITLE "Title" 73 #define APE_TAG_FIELD_SUBTITLE "Subtitle" 74 #define APE_TAG_FIELD_ARTIST "Artist" 75 #define APE_TAG_FIELD_ALBUMARTIST "Album Artist" 76 #define APE_TAG_FIELD_ALBUM "Album" 77 #define APE_TAG_FIELD_PART "Part" 78 #define APE_TAG_FIELD_DEBUTALBUM "Debut Album" 79 #define APE_TAG_FIELD_PUBLISHER "Publisher" 80 #define APE_TAG_FIELD_CONDUCTOR "Conductor" 81 #define APE_TAG_FIELD_COMPOSER "Composer" 82 #define APE_TAG_FIELD_COMMENT "Comment" 83 #define APE_TAG_FIELD_YEAR "Year" 84 #define APE_TAG_FIELD_RECORDDATE "Record Date" 85 #define APE_TAG_FIELD_RECORDLOCATION "Record Location" 86 #define APE_TAG_FIELD_TRACK "Track" 87 #define APE_TAG_FIELD_GENRE "Genre" 88 #define APE_TAG_FIELD_COVER_ART_FRONT "Cover Art (front)" 89 #define APE_TAG_FIELD_NOTES "Notes" 90 #define APE_TAG_FIELD_LYRICS "Lyrics" 91 #define APE_TAG_FIELD_COPYRIGHT "Copyright" 92 #define APE_TAG_FIELD_PUBLICATIONRIGHT "Publicationright" 93 #define APE_TAG_FIELD_FILE "File" 94 #define APE_TAG_FIELD_MEDIA "Media" 95 #define APE_TAG_FIELD_EANUPC "EAN/UPC" 96 #define APE_TAG_FIELD_ISRC "ISRC" 97 #define APE_TAG_FIELD_RELATED_URL "Related" 98 #define APE_TAG_FIELD_ABSTRACT_URL "Abstract" 99 #define APE_TAG_FIELD_BIBLIOGRAPHY_URL "Bibliography" 100 #define APE_TAG_FIELD_BUY_URL "Buy URL" 101 #define APE_TAG_FIELD_ARTIST_URL "Artist URL" 102 #define APE_TAG_FIELD_PUBLISHER_URL "Publisher URL" 103 #define APE_TAG_FIELD_FILE_URL "File URL" 104 #define APE_TAG_FIELD_COPYRIGHT_URL "Copyright URL" 105 #define APE_TAG_FIELD_INDEX "Index" 106 #define APE_TAG_FIELD_INTROPLAY "Introplay" 107 #define APE_TAG_FIELD_MJ_METADATA "Media Jukebox Metadata" 108 #define APE_TAG_FIELD_DUMMY "Dummy" 109 /**\}*/ 110 111 #define APE_TAG_LIB_FIRST "\02" /**< is using by #apefrm_get to get first frame */ 112 #define APE_TAG_LIB_NEXT "\03" /**< is using by #apefrm_get to get next frame you may check all frames this way */ 113 #define APE_TAG_LIB_DEL_ALL "\04" /**< is using by #apefrm_remove_real for removing all frames */ 114 115 116 /** 117 \name #apetag_save flags 118 \note default is #APE_TAG_V2 + #SAVE_NEW_OLD_APE_TAG + #SAVE_REMOVE_ID3V1 119 */ 120 /**\{*/ 121 #define APE_TAG_V1 (1 << 1) 122 #define APE_TAG_V2 (1 << 2) 123 #define SAVE_NEW_APE_TAG (1 << 3) 124 #define SAVE_NEW_OLD_APE_TAG (1 << 4) 125 #define SAVE_REMOVE_ID3V1 (1 << 5) 126 #define SAVE_CREATE_ID3V1_TAG (1 << 6) 127 #define SAVE_FAKE_SAVE (1 << 7) 128 /* apetag_read(_fp) flags - default read all (ape,id3v1,id3v2(if compiled)) */ 129 #define DONT_READ_TAG_APE (1 << 8) 130 #define DONT_READ_TAG_ID3V1 (1 << 9) 131 #define DONT_READ_TAG_ID3V2 (1 << 10) 132 /**\}*/ 133 134 135 /** 136 \name #atl_return 137 \brief return codes from all functions 138 \{ 139 */ 140 #define ATL_OK 0 /**< not using :) */ 141 #define ATL_FOPEN 1 /**< can't open file */ 142 #define ATL_FREAD 2 /**< can't read from file */ 143 #define ATL_FWRITE 3 /**< can't write to file (written bytes != bytes to write) */ 144 #define ATL_MALOC 4 /**< can't allocate memory */ 145 #define ATL_BADARG 5 /**< bad function argument */ 146 #define ATL_NOINIT 6 /**< not inited struct by apetag_init */ 147 /** \} */ 148 149 /** 150 \struct tag 151 \brief tag structure 152 153 i you get this <b>don't</b> change anything. copy all values/strings 154 */ 155 struct tag 156 { 157 char *name; /**< name of tag */ 158 char *value; /**< value of tag */ 159 size_t sizeName; /**< size of name in tag */ 160 size_t sizeValue; /**< size of value in tag */ 161 unsigned long flags; /**< flags of tag */ 162 }; 163 164 165 /** 166 object apetag used to store information about tag. 167 main object store **#tag , number of frames, current position for 168 APE_TAG_LIB_NEXT, etc 169 \brief object apetag used to store information about tag 170 **/ 171 typedef struct _ape_mem_cnt apetag; 172 173 174 /* 175 * function: 176 * apetag_*: for load/save/init file and structure 177 * apefrm_*: for add del edit one (or more) 178 * frame(, field, entry) in tag 179 */ 180 181 /* read file and add frames */ 182 int 183 apetag_read (apetag *mem_cnt, const char *filename, int flag) ; 184 185 /* read file and add frames */ 186 int 187 apetag_read_fp (apetag *mem_cnt, FILE * fp, const char *filename, int flag) ; 188 189 /* initialise new object #apetag and return */ 190 apetag * 191 apetag_init (void) ; 192 193 /* free #apetag object */ 194 void 195 apetag_free (apetag *mem_cnt) ; 196 197 /* save apetag to file */ 198 int 199 apetag_save (const char *filename, apetag *mem_cnt, int flag) ; 200 201 202 /* Add text frame */ 203 int 204 apefrm_add (apetag *mem_cnt, unsigned long flags, const char *name, const char *value) ; 205 206 /* add binary frame */ 207 int 208 apefrm_add_bin (apetag *mem_cnt, unsigned long flags, 209 long sizeName, char *name, long sizeValue, char *value); 210 211 /* add frame if other (the same name) no exist */ 212 int 213 apefrm_add_noreplace (apetag *mem_cnt, unsigned long flags, char *name, char *value) ; 214 215 /* search in apetag for name and return tag */ 216 struct tag * 217 apefrm_get (apetag *mem_cnt, const char *name) ; 218 219 /* search in apetag for name and return string */ 220 char * 221 apefrm_getstr (apetag *mem_cnt, const char *name) ; 222 223 /* remove frame from memory */ 224 void 225 apefrm_remove_real (apetag *mem_cnt, const char *name) ; 226 227 228 /** 229 \def apefrm_fake_remove(mem_cnt,name) 230 \brief set frame to remove 231 \deprecated remove in 0.5 232 */ 233 #define apefrm_fake_remove(mem_cnt,name) apefrm_remove(mem_cnt,name) 234 235 /* set frame to remove */ 236 void 237 apefrm_remove (apetag *mem_cnt, const char *name); 238 239 /* read id3v1 and add frames */ 240 int 241 readtag_id3v1_fp (apetag *mem_cnt, FILE * fp) ; 242 243 /** \name flags in frames and headers */ 244 /**\{*/ 245 //================================ 246 #define HEADER_IS 0x80000000 247 #define HEADER_NOT 0x00000000 248 #define HEADER_THIS_IS 0x20000000 249 //================================ 250 #define FOOTER_IS 0x00000000 251 #define FOOTER_NOT 0x40000000 252 #define FOOTER_THIS_IS 0x00000000 253 //================================ 254 #define ITEM_TEXT 0x00000000 255 #define ITEM_BIN 0x00000002 256 #define ITEM_LINK 0x00000004 257 #define ITEM_URL 0x00000004 // for compability ITEM_LINK 258 //================================ 259 #define TAG_RW 0x00000000 260 #define TAG_RO 0x00000001 261 /**\}*/ 262 263 /* debug function print all tags exclude bin (print only size for bin) */ 264 void 265 libapetag_print_mem_cnt (apetag *mem_cnt); 266 267 #endif /* _APETAGLIB_H */ 268