X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fid3.c;h=4b46b96b5eb874b92f6fe67148ef8bdce0ffb0b2;hb=755add816a5b297c5601f89b9c2fb049b6c7d6cf;hp=ab3dda7b88df6e1498189bfb2660bd7c20d3cdd0;hpb=45c0e948e8b98c5034d1e76e32c549063d185811;p=hvgrip.git diff --git a/src/id3.c b/src/id3.c index ab3dda7..4b46b96 100644 --- a/src/id3.c +++ b/src/id3.c @@ -23,11 +23,14 @@ #include #include #include -#include #include "grip_id3.h" +#include "common.h" 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: