/** * Copyright (c) 2005 Claudio Bustos * This code is hereby licensed for public consumption under the * GNU GPL v2. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "CdIo.h" Init_rb_cdio() { /** module CdIo */ mCdIo = rb_define_module("CdIo"); rb_define_module_function(mCdIo, "get_devices", rb_cdio_get_devices, -1); rb_define_module_function(mCdIo, "get_default_device", rb_cdio_get_default_device, -1); rb_define_module_function(mCdIo, "get_drive_cap_dev", rb_cdio_get_drive_cap_dev, 1); rb_define_module_function(mCdIo, "discmode_describe", rb_cdio_discmode_describe, 1); rb_define_module_function(mCdIo, "driver_describe", rb_cdio_driver_describe, 1); rb_define_module_function(mCdIo, "track_format_describe", rb_cdio_track_format_describe, 1); rb_define_module_function(mCdIo, "track_type_describe", rb_cdio_track_type_describe, 1); rb_define_module_function(mCdIo, "open", rb_cdio_open, -1); // is rb_define_module_function(mCdIo, "is_binfile", rb_cdio_is_binfile, 1); rb_define_module_function(mCdIo, "is_cuefile", rb_cdio_is_cuefile, 1); rb_define_module_function(mCdIo, "is_nrg", rb_cdio_is_nrg, 1); rb_define_module_function(mCdIo, "is_tocfile", rb_cdio_is_tocfile, 1); rb_define_module_function(mCdIo, "is_device",rb_cdio_is_device,-1); /** * class CdIo::Cd */ cCdIoCd = rb_define_class_under(mCdIo, "Cd", rb_cObject); rb_define_singleton_method(cCdIoCd, "new", rb_cdio_cd_new, -1); rb_define_method(cCdIoCd, "initialize", rb_cdio_cd_init, 2); int i; #define CDIO_ATTR 9 const char *attr[CDIO_ATTR] = { "device", "mcn", "driver_name", "driver_id", "first_track_num", "discmode", "num_tracks", "stat_size", "cddb_id" }; for (i = 0; i < CDIO_ATTR; i++) { rb_define_attr(cCdIoCd, attr[i], 1, 0); } rb_define_method(cCdIoCd, "get_tracks", rb_cdio_cd_get_tracks, 0); rb_define_method(cCdIoCd, "get_first_track", rb_cdio_cd_get_first_track, 0); rb_define_method(cCdIoCd, "get_arg", rb_cdio_cd_get_arg, 1); rb_define_method(cCdIoCd, "is_cd?", rb_cdio_cd_is_cd, 0); rb_define_method(cCdIoCd, "is_dvd?", rb_cdio_cd_is_dvd, 0); rb_define_method(cCdIoCd, "get_freedb", rb_cdio_cd_get_freedb, 0); rb_define_method(cCdIoCd, "get_cdtext", rb_cdio_cd_get_cdtext, 0); // device methods rb_define_method(cCdIoCd, "get_drive_cap", rb_cdio_cd_get_drive_cap, 0); rb_define_method(cCdIoCd, "get_hwinfo", rb_cdio_cd_get_hwinfo, 0); rb_define_method(cCdIoCd, "close", rb_cdio_cd_close, 0); /** class CdIo::Track */ cCdIoTrack = rb_define_class_under(mCdIo, "Track", rb_cObject); rb_define_method(cCdIoTrack, "initialize", rb_cdio_track_init, 2); rb_define_method(cCdIoTrack, "green?", rb_cdio_track_green, 0); rb_define_method(cCdIoTrack, "get_cdtext", rb_cdio_track_get_cdtext, 0); /** :cd :number :format, :green, :lba,:lsn,min,sec,frames,:sec_count*/ char attr2[11][32] = { "cd", "number", "format", "lba", "lsn", "min", "sec", "frames", "msf", "sec_count", "track_type" }; for (i = 0; i < 11; i++) { rb_define_attr(cCdIoTrack, attr2[i], 1, 0); } /** class CdIo::TrackIso9660 < CdIo::Track */ cCdIoTrackIso9660 = rb_define_class_under(mCdIo, "TrackIso9660", cCdIoTrack); char attr3[6][32] = { "system_id", "volume_id", "volumeset_id", "preparer_id", "publisher_id", "application_id" }; for (i = 0; i < 6; i++) { rb_define_attr(cCdIoTrackIso9660, attr3[i], 1, 0); } rb_define_method(cCdIoTrackIso9660, "initialize", rb_cdio_trackiso9660_init, 2); // const for DRIVER rb_define_const(mCdIo, "DRIVER_UNKNOWN", INT2FIX(DRIVER_UNKNOWN)); rb_define_const(mCdIo, "DRIVER_FREEBSD", INT2FIX(DRIVER_FREEBSD)); rb_define_const(mCdIo, "DRIVER_LINUX", INT2FIX(DRIVER_LINUX)); rb_define_const(mCdIo, "DRIVER_SOLARIS", INT2FIX(DRIVER_SOLARIS)); rb_define_const(mCdIo, "DRIVER_OSX", INT2FIX(DRIVER_OSX)); rb_define_const(mCdIo, "DRIVER_WIN32", INT2FIX(DRIVER_WIN32)); rb_define_const(mCdIo, "DRIVER_CDRDAO", INT2FIX(DRIVER_CDRDAO)); rb_define_const(mCdIo, "DRIVER_BINCUE", INT2FIX(DRIVER_BINCUE)); rb_define_const(mCdIo, "DRIVER_NRG", INT2FIX(DRIVER_NRG)); rb_define_const(mCdIo, "DRIVER_DEVICE", INT2FIX(DRIVER_DEVICE)); // const for CD types rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_DA", INT2FIX(CDIO_DISC_MODE_CD_DA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_DATA", INT2FIX(CDIO_DISC_MODE_CD_DATA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_XA", INT2FIX(CDIO_DISC_MODE_CD_XA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_MIXED", INT2FIX(CDIO_DISC_MODE_CD_MIXED)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_ROM", INT2FIX(CDIO_DISC_MODE_DVD_ROM)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_RAM", INT2FIX(CDIO_DISC_MODE_DVD_RAM)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_R", INT2FIX(CDIO_DISC_MODE_DVD_R)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_RW", INT2FIX(CDIO_DISC_MODE_DVD_RW)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_PR", INT2FIX(CDIO_DISC_MODE_DVD_PR)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_PRW", INT2FIX(CDIO_DISC_MODE_DVD_PRW)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_OTHER", INT2FIX(CDIO_DISC_MODE_DVD_OTHER)); rb_define_const(mCdIo, "CDIO_DISC_MODE_NO_INFO", INT2FIX(CDIO_DISC_MODE_NO_INFO)); rb_define_const(mCdIo, "CDIO_DISC_MODE_ERROR", INT2FIX(CDIO_DISC_MODE_ERROR)); }