Src/GetSCSICDBLength.c

/*                              GetSCSICDBLength.c                              */
/*
 * GetSCSICDBLength.c
 * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
 */
#include    "SCSIAsyncSample.h"
 
/*
 * Look at the "group code" in the command operation. Return zero (error) for
 * the reserved (3, 4) and vendor-specific command (6, 7) command groups.
 * Otherwise, return the command length from the group code value as specified
 * in the SCSI-II spec.
 */
short
GetSCSICDBLength(
        const SCSI_CommandPtr   scsiCommandPtr
    )
{
        short                   result;
        
        switch (scsiCommandPtr->scsi[0] & 0xE0) {
        case (0 << 5):  result = 6;     break;
        case (1 << 5):
        case (2 << 5):  result = 10;    break;
        case (5 << 5):  result = 12;    break;
        default:        result = 0;     break;
        }
        return (result);
}