From 70a56315ac97c82f688cb2bc35696dc744651973 Mon Sep 17 00:00:00 2001 From: "R. Bernstein" Date: Sun, 18 Mar 2012 13:34:21 -0400 Subject: [PATCH] Replace a few collections of preprocessor #define's with enum's. Savannah bug #35746 https://savannah.gnu.org/bugs/?35746 . Patch from Markus Elfring. --- include/cdio/dvd.h | 39 ++++++++++++++++++++++----------------- include/cdio/sector.h | 23 ++++++++++++++--------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/include/cdio/dvd.h b/include/cdio/dvd.h index bc337944..9d3f3389 100644 --- a/include/cdio/dvd.h +++ b/include/cdio/dvd.h @@ -35,27 +35,32 @@ /** Values used in a READ DVD STRUCTURE */ - -#define CDIO_DVD_STRUCT_PHYSICAL 0x00 -#define CDIO_DVD_STRUCT_COPYRIGHT 0x01 -#define CDIO_DVD_STRUCT_DISCKEY 0x02 -#define CDIO_DVD_STRUCT_BCA 0x03 -#define CDIO_DVD_STRUCT_MANUFACT 0x04 +typedef enum cdio_dvd_structure +{ + CDIO_DVD_STRUCT_PHYSICAL = 0x00, + CDIO_DVD_STRUCT_COPYRIGHT = 0x01, + CDIO_DVD_STRUCT_DISCKEY = 0x02, + CDIO_DVD_STRUCT_BCA = 0x03, + CDIO_DVD_STRUCT_MANUFACT = 0x04 +} cdio_dvd_structure; /** Media definitions for "DVD Book" from MMC-5 Table 400, page 419. */ -#define CDIO_DVD_BOOK_DVD_ROM 0x0 /**< DVD-ROM */ -#define CDIO_DVD_BOOK_DVD_RAM 0x1 /**< DVD-RAM */ -#define CDIO_DVD_BOOK_DVD_R 0x2 /**< DVD-R */ -#define CDIO_DVD_BOOK_DVD_RW 0x3 /**< DVD-RW */ -#define CDIO_DVD_BOOK_HD_DVD_ROM 0x4 /**< HD DVD-ROM */ -#define CDIO_DVD_BOOK_HD_DVD_RAM 0x5 /**< HD DVD-RAM */ -#define CDIO_DVD_BOOK_HD_DVD_R 0x6 /**< HD DVD-R */ -#define CDIO_DVD_BOOK_DVD_PRW 0x9 /**< DVD+RW */ -#define CDIO_DVD_BOOK_DVD_PR 0xa /**< DVD+R */ -#define CDIO_DVD_BOOK_DVD_PRW_DL 0xd /**< DVD+RW DL */ -#define CDIO_DVD_BOOK_DVD_PR_DL 0xe /**< DVD+R DL */ +typedef enum cdio_dvd_book +{ + CDIO_DVD_BOOK_DVD_ROM = 0x0, /**< DVD-ROM */ + CDIO_DVD_BOOK_DVD_RAM = 0x1, /**< DVD-RAM */ + CDIO_DVD_BOOK_DVD_R = 0x2, /**< DVD-R */ + CDIO_DVD_BOOK_DVD_RW = 0x3, /**< DVD-RW */ + CDIO_DVD_BOOK_HD_DVD_ROM = 0x4, /**< HD DVD-ROM */ + CDIO_DVD_BOOK_HD_DVD_RAM = 0x5, /**< HD DVD-RAM */ + CDIO_DVD_BOOK_HD_DVD_R = 0x6, /**< HD DVD-R */ + CDIO_DVD_BOOK_DVD_PRW = 0x9, /**< DVD+RW */ + CDIO_DVD_BOOK_DVD_PR = 0xa, /**< DVD+R */ + CDIO_DVD_BOOK_DVD_PRW_DL = 0xd, /**< DVD+RW DL */ + CDIO_DVD_BOOK_DVD_PR_DL = 0xe /**< DVD+R DL */ +} cdio_dvd_book; typedef struct cdio_dvd_layer { unsigned int book_version : 4; diff --git a/include/cdio/sector.h b/include/cdio/sector.h index c3644209..86857159 100644 --- a/include/cdio/sector.h +++ b/include/cdio/sector.h @@ -68,10 +68,13 @@ /*! Information that can be obtained through a Read Subchannel command. */ -#define CDIO_SUBCHANNEL_SUBQ_DATA 0 -#define CDIO_SUBCHANNEL_CURRENT_POSITION 1 -#define CDIO_SUBCHANNEL_MEDIA_CATALOG 2 -#define CDIO_SUBCHANNEL_TRACK_ISRC 3 + typedef enum cdio_subchannel + { + CDIO_SUBCHANNEL_SUBQ_DATA = 0, + CDIO_SUBCHANNEL_CURRENT_POSITION = 1, + CDIO_SUBCHANNEL_MEDIA_CATALOG = 2, + CDIO_SUBCHANNEL_TRACK_ISRC = 3 + } cdio_subchannel; /*! track flags * Q Sub-channel Control Field (4.2.3.3) @@ -198,12 +201,14 @@ #define CDIO_CD_FRAMES_PER_MIN \ (CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN) -#define CDIO_CD_74MIN_SECTORS (UINT32_C(74)*CDIO_CD_FRAMES_PER_MIN) -#define CDIO_CD_80MIN_SECTORS (UINT32_C(80)*CDIO_CD_FRAMES_PER_MIN) -#define CDIO_CD_90MIN_SECTORS (UINT32_C(90)*CDIO_CD_FRAMES_PER_MIN) +typedef enum cdio_cd_minutes_sectors +{ + CDIO_CD_74MIN_SECTORS = UINT32_C(74) * CDIO_CD_FRAMES_PER_MIN, + CDIO_CD_80MIN_SECTORS = UINT32_C(80) * CDIO_CD_FRAMES_PER_MIN, + CDIO_CD_90MIN_SECTORS = UINT32_C(90) * CDIO_CD_FRAMES_PER_MIN, -#define CDIO_CD_MAX_SECTORS \ - (UINT32_C(100)*CDIO_CD_FRAMES_PER_MIN-CDIO_PREGAP_SECTORS) + CDIO_CD_MAX_SECTORS = UINT32_C(100) * CDIO_CD_FRAMES_PER_MIN - CDIO_PREGAP_SECTORS +} cdio_cd_minutes_sectors; #define msf_t_SIZEOF 3