Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. cddb.c
  5. Abstract:
  6. cddb support
  7. Environment:
  8. User mode only
  9. Revision History:
  10. 05-26-98 : Created
  11. --*/
  12. #include "common.h"
  13. ULONG
  14. CDDB_ID(
  15. PCDROM_TOC toc
  16. )
  17. {
  18. ULONG i,n,j;
  19. ULONG cddbSum;
  20. ULONG totalLength;
  21. ULONG totalTracks;
  22. ULONG finalDiscId;
  23. i = 0;
  24. n = 0;
  25. totalTracks = toc->LastTrack - toc->FirstTrack;
  26. totalTracks++; // MCI difference
  27. while (i < totalTracks) {
  28. // cddb_sum
  29. cddbSum = 0;
  30. j = (toc->TrackData[i].Address[1] * 60) +
  31. (toc->TrackData[i].Address[2]);
  32. while (j > 0) {
  33. cddbSum += j % 10;
  34. j /= 10;
  35. }
  36. n += cddbSum;
  37. i++;
  38. }
  39. // compute total cd length in seconds
  40. totalLength =
  41. ((toc->TrackData[totalTracks].Address[1] * 60) +
  42. (toc->TrackData[totalTracks].Address[2])
  43. ) -
  44. ((toc->TrackData[0].Address[1] * 60) +
  45. (toc->TrackData[0].Address[2])
  46. );
  47. finalDiscId = (((n % 0xff) << 24) |
  48. (totalLength << 8) |
  49. (totalTracks)
  50. );
  51. return finalDiscId;
  52. }