1 /* read mp3 header & tag, author: hackbard */
12 #define ID_TAG_SIZE 128
13 #define MAX_BUF_SIZE 32
18 #define MAX_COMMENT 30
21 #define MAX_FILENAME 32
26 http://www.dv.co.yu/mpgscript/mpeghdr.htm
29 int main (int argc,char **argv)
33 unsigned char buf[MAX_BUF_SIZE];
34 char filename[MAX_FILENAME];
36 strcpy(filename,argv[1]);
37 file_size=atoi(argv[2]);
39 if((file_fd=open(filename,O_RDONLY))<=0) {
44 if((lseek(file_fd,file_size-ID_TAG_SIZE,SEEK_SET))<0) {
45 puts("cannot seek to id tag");
50 if((read(file_fd,&buf,3))<3) {
51 puts("read failed (1)");
55 if(strncmp(buf,"TAG",3)) {
56 puts("TAG not found");
60 read(file_fd,&buf,MAX_TITLE);
61 printf("title: %s\n",buf);
63 read(file_fd,&buf,MAX_ARTIST);
64 printf("artist: %s\n",buf);
66 read(file_fd,&buf,MAX_ALBUM);
67 printf("album: %s\n",buf);
69 read(file_fd,&buf,MAX_YEAR);
70 printf("year: %s\n",buf);
72 read(file_fd,&buf,MAX_COMMENT);
73 printf("comment: %s\n",buf);
75 read(file_fd,&buf,MAX_GENRE);
76 printf("genre: %c\n",*buf);