|
From: Ben O. <ben...@us...> - 2002-02-26 02:23:40
|
Update of /cvsroot/njbfs/njbfs
In directory usw-pr-cvs1:/tmp/cvs-serv449
Modified Files:
Tag: ben
proc.c
Log Message:
ben: whoops back that out
Index: proc.c
===================================================================
RCS file: /cvsroot/njbfs/njbfs/proc.c,v
retrieving revision 1.6.2.4
retrieving revision 1.6.2.5
diff -C2 -d -r1.6.2.4 -r1.6.2.5
*** proc.c 26 Feb 2002 02:20:05 -0000 1.6.2.4
--- proc.c 26 Feb 2002 02:23:38 -0000 1.6.2.5
***************
*** 428,431 ****
--- 428,520 ----
}
+ int write_id3_frame(char *buf, char *id, char *val)
+ {
+ u_int32_t size;
+ int i, count = 0;
+
+ for (i = 0; i < 4; i++, count++) {
+ buf[count] = id[i];
+ }
+ size = __cpu_to_be32((u_int32_t) strlen(val) + 1);
+
+ memcpy((void *) buf + count, &size, 4);
+ count += 4;
+
+ /* defaults for frame header tag, zero */
+ buf[count++] = 0x0;
+ buf[count++] = 0x0;
+
+ /* this signifies iso-whatever (standard) encoding */
+ buf[count++] = 0x0;
+
+ for (i = 0; val[i]; i++)
+ buf[count++] = val[i];
+
+ return count;
+ }
+
+ int write_id3_frame_numeric(char *buf, char *id, u_int32_t val)
+ {
+ static char vbuf[80];
+ sprintf(vbuf, "%u", val);
+ return write_id3_frame(buf, id, vbuf);
+ }
+
+ int create_id3_tag(struct dentry *dentry, char *buffer)
+ {
+ struct njbfs_fattr *fattr;
+ char *p = buffer;
+ struct njbfs_sb_info *info =
+ (struct njbfs_sb_info *) dentry->d_inode->i_sb->u.generic_sbp;
+ u_int32_t size = NJBFS_ID3SIZE - 10;
+ /* our blocksize minus 10 for the tag header */
+ int i;
+
+ njbfs_read_lock(dentry->d_inode);
+ fattr = njbfs_get_attr_nolock(dentry, info);
+ if ( ! fattr )
+ return -EINVAL;
+ njbfs_read_unlock(dentry->d_inode);
+
+ memset(buffer, 0, NJBFS_BLOCKSIZE);
+
+ strcat(buffer, "ID3");
+
+ /* set to version 2.3.0 */
+ buffer[3] = 0x03;
+ buffer[4] = 0x00;
+
+ /* all id3 flags empty */
+ buffer[5] = 0x00;
+
+ /* id3 uses a 28 bit number for tag size. how odd. */
+ for (i = 0; i <= 4; i++) {
+ buffer[9 - i] = (char) size & 0x7F;
+ size >>= 7;
+ }
+
+ p = buffer + 10;
+ /* write da tags, biznatch */
+ if ( fattr->artist )
+ p += write_id3_frame(p, "TPE1", fattr->artist);
+
+ if ( fattr->title )
+ p += write_id3_frame(p, "TIT2", fattr->title);
+
+ if ( fattr->album )
+ p += write_id3_frame(p, "TALB", fattr->album);
+
+ if ( fattr->genre )
+ p += write_id3_frame(p, "TCON", fattr->genre);
+
+ if ( fattr->tracknum )
+ p += write_id3_frame_numeric(p, "TRCK", fattr->tracknum);
+
+ if ( fattr->year )
+ p += write_id3_frame_numeric(p, "TYER", fattr->year);
+
+ return 0;
+ }
+
/*
we pass this function into generic_file_read.
***************
*** 678,683 ****
return bytes + faked;
}
-
-
/**
--- 767,770 ----
|