libdm_misc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. libdm_misc.h - libdiscmage miscellaneous
  3. Copyright (c) 2002 - 2003 NoisyB
  4. Copyright (c) 2002 - 2004 dbjh
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #ifndef LIBDM_MISC_H
  18. #define LIBDM_MISC_H
  19. /*
  20. libdm messages
  21. usage example: fprintf (stdout, dm_msg[DEPRECATED], filename);
  22. */
  23. enum
  24. {
  25. DEPRECATED = 0,
  26. UNKNOWN_IMAGE,
  27. ALREADY_2048,
  28. ALPHA
  29. };
  30. extern const char *dm_msg[];
  31. typedef struct
  32. {
  33. int mode;
  34. int seek_header; // sync, head, sub
  35. int sector_size; // data
  36. int seek_ecc; // EDC, zero, ECC, spare
  37. int id;
  38. const char *suffix;
  39. } st_track_probe_t;
  40. extern const st_track_probe_t track_probe[];
  41. typedef struct
  42. {
  43. int id;
  44. const char *desc;
  45. } st_track_desc_t; // used in toc.c and cue.c
  46. enum {
  47. DM_AUDIO = 1,
  48. #if 0
  49. DM_SIZERAW,
  50. DM_SIZEISO_MODE1,
  51. DM_SIZEISO_MODE2_RAW,
  52. DM_SIZEISO_MODE2_FORM1,
  53. DM_SIZEISO_MODE2_FORM2,
  54. DM_MODE1,
  55. DM_MODE2,
  56. #endif
  57. DM_MODE1_2352,
  58. DM_MODE2_2352,
  59. DM_MODE1_2048,
  60. DM_MODE2_2336
  61. };
  62. enum {
  63. DM_UNKNOWN = -1,
  64. DM_CUE = 1,
  65. DM_TOC,
  66. DM_CDI,
  67. DM_NRG,
  68. // DM_CCD,
  69. DM_OTHER
  70. };
  71. /*
  72. dm_get_track_desc() returns a string like "MODE1/2352" depending on the
  73. mode and sector_size specified; if cue == FALSE
  74. it will return the string in TOC format
  75. */
  76. extern int dm_get_track_mode_id (int mode, int sector_size);
  77. extern void dm_get_track_mode_by_id (int id, int8_t *mode, uint16_t *sector_size);
  78. extern void dm_clean (dm_image_t *image);
  79. extern void dm_gauge (int, int);
  80. extern const char pvd_magic[];
  81. extern const char svd_magic[];
  82. extern const char vdt_magic[];
  83. /*
  84. dm_lba_to_msf() convert LBA to minutes, seconds, frames
  85. dm_msf_to_lba() convert minutes, seconds, frames to LBA
  86. LBA represents the logical block address for the CD-ROM absolute
  87. address field or for the offset from the beginning of the current track
  88. expressed as a number of logical blocks in a CD-ROM track relative
  89. address field.
  90. MSF represents the physical address written on CD-ROM discs,
  91. expressed as a sector count relative to either the beginning of the
  92. medium or the beginning of the current track.
  93. dm_bcd_to_int() convert BCD to integer
  94. dm_int_to_bcd() convert integer to BCD
  95. */
  96. extern int dm_lba_to_msf (int lba, int *m, int *s, int *f);
  97. extern int dm_msf_to_lba (int m, int s, int f, int force_positive);
  98. extern int dm_bcd_to_int (int b);
  99. extern int dm_int_to_bcd (int i);
  100. #endif // LIBDM_MISC_H