thanks to Evan Jones and this page
http://developer.apple.com/documentation/DeviceDrivers/Conceptual/WorkingWStorage/WWStorage_StorageDevs/StorageDevFiles.html,
I wrote this patch, which still does not do the whole job...
(the problem is the change between little_endian and big_endian)
on that same CD, I now get this:
af09b90d 13 150 5746 21363 30465 53061 69840 84564 100299 121212
125762 141761 158858 164852 2491
differing only slightly from the correct one:
af09bc0d 13 150 5746 21363 30465 53061 69840 84564 100299 121212
125762 141761 158858 164852 2494
anybody can explain these 3 seconds difference (which are also
the same 3 units
difference between 0x09b9 and 0x09bc)?
RCS file: cd-discid.c,v
retrieving revision 1.1
diff -ubB -r1.1 cd-discid.c
--- cd-discid.c 2009/04/25 22:59:52 1.1
+++ cd-discid.c 2009/04/25 23:07:18
@@ -90,6 +90,22 @@
# error "Your OS isn't supported yet."
#endif /* os selection */
+unsigned long byte_swap(unsigned long big_endian)
+{
+#if defined(__LITTLE_ENDIAN__)
+ unsigned long little_endian = 0;
+ int j = 0;
+ for (j=0; j<4; j++) {
+ little_endian *= 256;
+ little_endian += big_endian % 256;
+ big_endian /= 256;
+ }
+ return little_endian;
+#elif defined(__BIG_ENDIAN__)
+ return big_endian;
+#endif
+}
+
int cddb_sum (int n)
{
/* a number like 2344 becomes 2+3+4+4 (13) */
@@ -222,11 +237,11 @@
#if defined(__FreeBSD__)
TocEntry[i].cdte_track_address =
ntohl(TocEntry[i].cdte_track_address);
#endif
- cksum += cddb_sum((TocEntry[i].cdte_track_address
+ CD_MSF_OFFSET) / CD_FRAMES);
+ cksum += cddb_sum((byte_swap(TocEntry[i].cdte_tra
ck_address) + CD_MSF_OFFSET)
/ CD_FRAMES);
}
- totaltime = ((TocEntry[last].cdte_track_address + CD_MSF_
OFFSET) / CD_FRAMES) -
- ((TocEntry[0].cdte_track_address + CD_MSF_OFF
SET) / CD_FRAMES);
+ totaltime = ((byte_swap(TocEntry[last].cdte_track_address)
+ CD_MSF_OFFSET) /
CD_FRAMES) -
+ ((byte_swap(TocEntry[0].cdte_track_address) + CD_MSF_OFFSET
) / CD_FRAMES);
/* print discid */
printf("%08lx", (cksum % 0xff) << 24 | totaltime << 8 | la
st);
@@ -236,11 +251,11 @@
/* print frame offsets of all tracks */
for (i = 0; i < last; i++) {
- printf(" %d", TocEntry[i].cdte_track_address + CD_
MSF_OFFSET);
+ printf(" %d", byte_swap(TocEntry[i].cdte_track_add
ress) + CD_MSF_OFFSET);
}
/* print length of disc in seconds */
- printf(" %d\n", (TocEntry[last].cdte_track_address + CD_M
SF_OFFSET) /
CD_FRAMES);
+ printf(" %d\n", (byte_swap(TocEntry[last].cdte_track_address) +
CD_MSF_OFFSET) / CD_FRAMES);
free(TocEntry);
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Fink-beginners mailing list
[email protected]
http://news.gmane.org/gmane.os.apple.fink.beginners