📄 setup.c
字号:
/* setup -- setup and reset cd writer Copyright (C) 1996 Dieter Baron and Armin Obersteiner This file is part of cdwrite. The authors can be contacted at <dillo@giga.or.at> <armin.obersteiner@giga.or.at> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. 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., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include <stdio.h>#include <scsi/all.h>#include <scsi/hp.h>#include <scsi/cdr102.h>#include "cdwrite.h"struct { struct sc_mode_block_descriptor bdesc; struct sc_mode_hp_speed page;} hp_restore;struct { struct sc_mode_header6 header; struct sc_mode_block_descriptor bdesc; struct sc_mode_hp_speed page;} hp_tmp;struct { struct sc_mode_block_descriptor bdesc; struct sc_mode_cdr102_conf page;} yama_restore;struct { struct sc_mode_header6 header; struct sc_mode_block_descriptor bdesc; struct sc_mode_cdr102_conf page;} yama_tmp;intsetup(int speed, int dummy){ u_char b[256]; /* if (sc_da_prevent_allow_medium_removal(scsi, 1) < 0) { sc_fstatus(scsi, stderr, prg, "prevent-allow-medium-removal", 3); return 1; } */ switch (mode) { case 0: /* hp */ case 1: /* philips */ case 2: case 3: /* remember page */ if (sc_mode_sense6(scsi, SC_MODE_HP_SPEED, 0, 0, 255, b) < 0) { sc_fstatus(scsi, stderr, prg, "mode-sense-6", 3); return 1; } memcpy(&hp_restore.bdesc, b+4, sizeof(hp_restore.bdesc)); memcpy(&hp_restore.page, b+4+b[3]*8, sizeof(hp_restore.page)); /* initialize and set new page */ memset(&hp_tmp, 0, sizeof(hp_tmp)); hp_tmp.header.bdno = 1; hp_tmp.page = hp_restore.page; hp_tmp.page.speed = speed; hp_tmp.page.emu = dummy; hp_tmp.bdesc = hp_restore.bdesc; sc_store_l((char *)&hp_tmp.bdesc.r4, 2048); if (sc_mode_select6(scsi, 1, 0, sizeof(hp_tmp), (u_char *)&hp_tmp) < 0) { sc_fstatus(scsi, stderr, prg, "mode-select-6", 3); return 1; } break; case 4: /* yamaha */ /* remember page */ if (sc_mode_sense6(scsi, SC_MODE_CDR102_CONF, 0, 0, 255, b) < 0) { sc_fstatus(scsi, stderr, prg, "mode-sense-6", 3); return 1; } memcpy(&yama_restore.bdesc, b+4, sizeof(yama_restore.bdesc)); memcpy(&yama_restore.page, b+4+b[3]*8, sizeof(yama_restore.page)); /* initialize and set new page */ memset(&yama_tmp, 0, sizeof(yama_tmp)); yama_tmp.header.bdno = 1; yama_tmp.bdesc = yama_restore.bdesc; yama_tmp.page = yama_restore.page; yama_tmp.page.speed = speed/2; yama_tmp.page.emu = dummy; if (sc_mode_select6(scsi, 1, 0, sizeof(yama_tmp), (u_char *)&yama_tmp) < 0) { sc_fstatus(scsi, stderr, prg, "mode-select-6", 3); return 1; } break; } return 0;}intcleanup(void){ switch (mode) { case 0: /* hp */ case 1: /* philips */ case 2: case 3: /* reset mode page */ hp_tmp.bdesc = hp_restore.bdesc; hp_tmp.page = hp_restore.page; if (sc_mode_select6(scsi, 1, 0, sizeof(hp_tmp), (u_char *)&hp_tmp) < 0) { sc_fstatus(scsi, stderr, prg, "mode-select-6", 3); return 1; } break; case 4: /* yamaha */ /* reset mode page */ yama_tmp.bdesc = yama_restore.bdesc; yama_tmp.page = yama_restore.page; if (sc_mode_select6(scsi, 1, 0, sizeof(yama_tmp), (u_char *)&yama_tmp) < 0) { sc_fstatus(scsi, stderr, prg, "mode-select-6", 3); return 1; } break; }/* if (sc_da_prevent_allow_medium_removal(scsi, 0) < 0) { sc_fstatus(scsi, stderr, prg, "prevent-allow-medium-removal", 3); return 1; } */ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -