static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)

{

    switch (buf[0]) {

    /* stream commands */

    case ERASE_12:

    case ERASE_16:

        cmd->xfer = 0;

        break;

    case READ_6:

    case READ_REVERSE:

    case RECOVER_BUFFERED_DATA:

    case WRITE_6:

        cmd->len = 6;

        cmd->xfer = buf[4] | (buf[3] << 8) | (buf[2] << 16);

        if (buf[1] & 0x01) { /* fixed */

            cmd->xfer *= dev->blocksize;

        }

        break;

    case READ_16:

    case READ_REVERSE_16:

    case VERIFY_16:

    case WRITE_16:

        cmd->len = 16;

        cmd->xfer = buf[14] | (buf[13] << 8) | (buf[12] << 16);

        if (buf[1] & 0x01) { /* fixed */

            cmd->xfer *= dev->blocksize;

        }

        break;

    case REWIND:

    case LOAD_UNLOAD:

        cmd->len = 6;

        cmd->xfer = 0;

        break;

    case SPACE_16:

        cmd->xfer = buf[13] | (buf[12] << 8);

        break;

    case READ_POSITION:

        cmd->xfer = buf[8] | (buf[7] << 8);

        break;

    case FORMAT_UNIT:

        cmd->xfer = buf[4] | (buf[3] << 8);

        break;

    /* generic commands */

    default:

        return scsi_req_length(cmd, dev, buf);

    }

    return 0;

}

static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)

{

    switch (buf[0]) {

    

    case ERASE_12:

    case ERASE_16:

        cmd->xfer = 0;

        break;

    case READ_6:

    case READ_REVERSE:

    case RECOVER_BUFFERED_DATA:

    case WRITE_6:

        cmd->len = 6;

        cmd->xfer = buf[4] | (buf[3] << 8) | (buf[2] << 16);

        if (buf[1] & 0x01) { 

            cmd->xfer *= dev->blocksize;

        }

        break;

    case READ_16:

    case READ_REVERSE_16:

    case VERIFY_16:

    case WRITE_16:

        cmd->len = 16;

        cmd->xfer = buf[14] | (buf[13] << 8) | (buf[12] << 16);

        if (buf[1] & 0x01) { 

            cmd->xfer *= dev->blocksize;

        }

        break;

    case REWIND:

    case LOAD_UNLOAD:

        cmd->len = 6;

        cmd->xfer = 0;

        break;

    case SPACE_16:

        cmd->xfer = buf[13] | (buf[12] << 8);

        break;

    case READ_POSITION:

        cmd->xfer = buf[8] | (buf[7] << 8);

        break;

    case FORMAT_UNIT:

        cmd->xfer = buf[4] | (buf[3] << 8);

        break;

    

    default:

        return scsi_req_length(cmd, dev, buf);

    }

    return 0;

}

static int FUNC_0(SCSICommand *VAR_0, SCSIDevice *VAR_1, uint8_t *VAR_2)

{

    switch (VAR_2[0]) {

    

    case ERASE_12:

    case ERASE_16:

        VAR_0->xfer = 0;

        break;

    case READ_6:

    case READ_REVERSE:

    case RECOVER_BUFFERED_DATA:

    case WRITE_6:

        VAR_0->len = 6;

        VAR_0->xfer = VAR_2[4] | (VAR_2[3] << 8) | (VAR_2[2] << 16);

        if (VAR_2[1] & 0x01) { 

            VAR_0->xfer *= VAR_1->blocksize;

        }

        break;

    case READ_16:

    case READ_REVERSE_16:

    case VERIFY_16:

    case WRITE_16:

        VAR_0->len = 16;

        VAR_0->xfer = VAR_2[14] | (VAR_2[13] << 8) | (VAR_2[12] << 16);

        if (VAR_2[1] & 0x01) { 

            VAR_0->xfer *= VAR_1->blocksize;

        }

        break;

    case REWIND:

    case LOAD_UNLOAD:

        VAR_0->len = 6;

        VAR_0->xfer = 0;

        break;

    case SPACE_16:

        VAR_0->xfer = VAR_2[13] | (VAR_2[12] << 8);

        break;

    case READ_POSITION:

        VAR_0->xfer = VAR_2[8] | (VAR_2[7] << 8);

        break;

    case FORMAT_UNIT:

        VAR_0->xfer = VAR_2[4] | (VAR_2[3] << 8);

        break;

    

    default:

        return scsi_req_length(VAR_0, VAR_1, VAR_2);

    }

    return 0;

}

static int FUNC_0(SCSICommand *VAR_0, SCSIDevice *VAR_1, uint8_t *VAR_2)
{ switch (VAR_2[0]) { case ERASE_12:
case ERASE_16:
VAR_0->xfer = 0; break; case READ_6:
case READ_REVERSE:
case RECOVER_BUFFERED_DATA:
case WRITE_6:
VAR_0->len = 6; VAR_0->xfer = VAR_2[4] | (VAR_2[3] << 8) | (VAR_2[2] << 16); if (VAR_2[1] & 0x01) { VAR_0->xfer *= VAR_1->blocksize; } break; case READ_16:
case READ_REVERSE_16:
case VERIFY_16:
case WRITE_16:
VAR_0->len = 16; VAR_0->xfer = VAR_2[14] | (VAR_2[13] << 8) | (VAR_2[12] << 16); if (VAR_2[1] & 0x01) { VAR_0->xfer *= VAR_1->blocksize; } break; case REWIND:
case LOAD_UNLOAD:
VAR_0->len = 6; VAR_0->xfer = 0; break; case SPACE_16:
VAR_0->xfer = VAR_2[13] | (VAR_2[12] << 8); break; case READ_POSITION:
VAR_0->xfer = VAR_2[8] | (VAR_2[7] << 8); break; case FORMAT_UNIT:
VAR_0->xfer = VAR_2[4] | (VAR_2[3] << 8); break; default:
return scsi_req_length(VAR_0, VAR_1, VAR_2); } return 0; }