X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fid3.c;h=4b46b96b5eb874b92f6fe67148ef8bdce0ffb0b2;hb=HEAD;hp=46c89bf80f7c82f1276e2bc9bcb30b25cb427277;hpb=71083c96d08795256c46411dab74efb0383e8ee2;p=hvgrip.git diff --git a/src/id3.c b/src/id3.c index 46c89bf..4b46b96 100644 --- a/src/id3.c +++ b/src/id3.c @@ -28,6 +28,9 @@ static void ID3Put(char *dest,char *src,int len,char *encoding); +#define GENRE_MAX_DIGITS 6 +#define TRACK_MAX_DIGITS 3 + /* this array contains string representations of all known ID3 tags */ /* taken from mp3id3 in the mp3tools 0.7 package */ @@ -216,6 +219,11 @@ typedef struct _id3_tag { #ifdef HAVE_ID3V2 +/* + * id3lib, in a very stupid way, has a public bool typedef. + * This creates a compilation error if we are including + */ +#undef bool #include /* Things you might want to mess with. Surprisingly, the code will probably @@ -252,8 +260,8 @@ gboolean ID3v2TagFile(char *filename, char *title, char *artist, char *album, if ( frames[ i ] ) { char *c_data = NULL; - char gen[ 5 ] = "( )"; - char trk[ 4 ] = " "; + char gen[ GENRE_MAX_DIGITS ] = "( )"; /* max unsigned char: 255 */ + char trk[ TRACK_MAX_DIGITS ] = " "; /* max CDDA tracks: 99 */ switch( frameids[ i ] ) { case ID3FID_TITLE: @@ -278,12 +286,12 @@ gboolean ID3v2TagFile(char *filename, char *title, char *artist, char *album, case ID3FID_CONTENTTYPE: c_data = gen; - sprintf( gen, "(%d)", genre ); /* XXX */ + snprintf( gen, GENRE_MAX_DIGITS, "(%d)", genre ); break; case ID3FID_TRACKNUM: c_data = trk; - sprintf( trk, "%d", tracknum ); /* XXX */ + snprintf( trk, TRACK_MAX_DIGITS, "%d", tracknum ); break; default: