ftp.nice.ch/pub/next/tools/scsi/SCSI2_ToolBox.940921.NI.bs.tar.gz#/SCSI2_ToolBox/SCSI2_Kit/Source/CDSCSI.m

This is CDSCSI.m in view mode; [Download] [Up]

//
//	CDSCSI_Class - subclass of SCSI2_Class for CD disk drive devices
//
//	Copyright (C) 1994 by Christopher Wolf.
//
//	This library is free software; you can redistribute it and/or
//	modify it under the terms of the GNU Library General Public
//	License as published by the Free Software Foundation; either
//	version 2 of the License, or (at your option) any later version.
//
//	This library is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//	Library General Public License for more details.
//
//	You should have received a copy of the GNU Library General Public
//	License along with this library; if not, write to the Free
//	Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//	Bug-reports, comments and questions should be directed to:
//		Christopher Wolf <chris@alchemy.geo.cornell.edu>
//
//	Portions of this code and documentation are derived from an 
//	earlier work (SCSI Inquirer) Copyright (C) 1990, 1991, 1992 by 
//	Jiro Nakamura and used with permission.
//

//
// 	For best results view this file with a tab size of 4 and
//	a display width of 132 columns or wider.
//

//	file version information
#define RCSCDM "$Id: CDSCSI.m,v 0.10 94/09/19 22:40:31 chris Exp Locker: chris $"

//	generic Unix headers
#import <stdio.h>
#import <libc.h>

// 	NeXTSTEP headers
#import <appkit/appkit.h>

//	SCSI2 class specific headers 
#import "CDSCSI.h"

// string constants
const char RCScdm[] = RCSCDM;
const char RCScdh[] = RCSCDH;

@implementation CDSCSI


//	----------------------------------------------------------------------
//
//	NAME
//		isDevice
//
//	RETURNS
//		(BOOL)			YES if sub-class can handle device, NO otherwise. 
//
//	EXPLANATION
//		It is the sub-classes responsibility to implement this method. 
//		The method should return YES if the subclass of SCSI can handle
//		the device at the current target, NO otherwise.  
//
//	SEE ALSO
//		findDevice (SCSI), findDevice: (SCSI)
//	
//	----------------------------------------------------------------------
	
- (BOOL) isDevice
	{

	struct inquiry2_reply ibuffer;
	BOOL result = NO;
	
	if ((![self inquiry: &ibuffer]) && (ibuffer.ir_devicetype == DEVTYPE_CDROM))
		{
		result = YES;
		}
	
	return result;
	
	}

- (int) eject
	{

	struct cdb_start_stop *cdbp = (struct cdb_start_stop *)&sr.sr_cdb.cdb_c6;
	BOOL wasOpen = isOpen;
	int result = -1;
	
	if (wasOpen || ![self open])
		{
			
		[SCSI clearCommandBlock: (union cdb *) cdbp];
		
		cdbp->ss_opcode = C6OP_STARTSTOP;
		cdbp->ss_lun    = lun;
		cdbp->ss_loej	= 1;
		
		sr.sr_dma_dir	= SR_DMA_RD;
		sr.sr_addr		= NULL;
		sr.sr_dma_max   = 0;
		sr.sr_ioto		= 10;	

		result = [self performRequest];	

		}
		
	if (!wasOpen && [self close])
		{
		result = -1;
		}

	return(result);		

	}

- (int) playFromMSF:(u_char)firstMinute:(u_char)firstSecond:(u_char)firstFrame
	ToMSF:(u_char)lastMinute:(u_char)lastSecond:(u_char)lastFrame
	{
	
	struct cdb_play_audio_msf *cdbp = (struct cdb_play_audio_msf *)&sr.sr_cdb.cdb_c10;
	BOOL wasOpen = isOpen;
	int result = -1;
	
	if (wasOpen || ![self open])
		{
			
		[SCSI clearCommandBlock: (union cdb *) cdbp];
		
		cdbp->pam_opcode 	= C10OP_PLAYAUDIOMSF;
		cdbp->pam_start_m 	= firstMinute;
		cdbp->pam_start_s	= firstSecond;
		cdbp->pam_start_f	= firstFrame;
		cdbp->pam_end_m		= lastMinute;
		cdbp->pam_end_s		= lastSecond;
		cdbp->pam_end_f		= lastFrame;
				
		sr.sr_dma_dir	= SR_DMA_RD;
		sr.sr_addr		= NULL;
		sr.sr_dma_max   = 0;
		sr.sr_ioto		= 10;	

		result = [self performRequest];	

		}
		
	if (!wasOpen && [self close])
		{
		result = -1;
		}

	return(result);		

	}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.