libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009-2011, 2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/ac/linux/cdrom.h> 00020 00021 #include <libexplain/buffer/cdrom_generic_command.h> 00022 #include <libexplain/buffer/hexdump.h> 00023 #include <libexplain/buffer/long.h> 00024 #include <libexplain/buffer/pointer.h> 00025 #include <libexplain/parse_bits.h> 00026 #include <libexplain/is_efault.h> 00027 #include <libexplain/sizeof.h> 00028 00029 00030 #ifdef CDROM_SEND_PACKET 00031 00032 static void 00033 explain_buffer_data_direction(explain_string_buffer_t *sb, int dir) 00034 { 00035 static const explain_parse_bits_table_t table[] = 00036 { 00037 { "CGC_DATA_UNKNOWN", CGC_DATA_UNKNOWN }, 00038 { "CGC_DATA_WRITE", CGC_DATA_WRITE }, 00039 { "CGC_DATA_READ", CGC_DATA_READ }, 00040 { "CGC_DATA_NONE", CGC_DATA_NONE }, 00041 }; 00042 00043 explain_parse_bits_print_single(sb, dir, table, SIZEOF(table)); 00044 } 00045 00046 00047 static void 00048 explain_buffer_gpcmd(explain_string_buffer_t *sb, int cmd) 00049 { 00050 static const explain_parse_bits_table_t table[] = 00051 { 00052 { "GPCMD_BLANK", GPCMD_BLANK }, 00053 { "GPCMD_CLOSE_TRACK", GPCMD_CLOSE_TRACK }, 00054 { "GPCMD_FLUSH_CACHE", GPCMD_FLUSH_CACHE }, 00055 { "GPCMD_FORMAT_UNIT", GPCMD_FORMAT_UNIT }, 00056 { "GPCMD_GET_CONFIGURATION", GPCMD_GET_CONFIGURATION }, 00057 { "GPCMD_GET_EVENT_STATUS_NOTIFICATION", 00058 GPCMD_GET_EVENT_STATUS_NOTIFICATION }, 00059 { "GPCMD_GET_PERFORMANCE", GPCMD_GET_PERFORMANCE }, 00060 { "GPCMD_INQUIRY", GPCMD_INQUIRY }, 00061 { "GPCMD_LOAD_UNLOAD", GPCMD_LOAD_UNLOAD }, 00062 { "GPCMD_MECHANISM_STATUS", GPCMD_MECHANISM_STATUS }, 00063 { "GPCMD_MODE_SELECT_10", GPCMD_MODE_SELECT_10 }, 00064 { "GPCMD_MODE_SENSE_10", GPCMD_MODE_SENSE_10 }, 00065 { "GPCMD_PAUSE_RESUME", GPCMD_PAUSE_RESUME }, 00066 { "GPCMD_PLAY_AUDIO_10", GPCMD_PLAY_AUDIO_10 }, 00067 { "GPCMD_PLAY_AUDIO_MSF", GPCMD_PLAY_AUDIO_MSF }, 00068 { "GPCMD_PLAY_AUDIO_TI", GPCMD_PLAY_AUDIO_TI }, 00069 { "GPCMD_PLAY_CD", GPCMD_PLAY_CD }, 00070 { "GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL", 00071 GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL }, 00072 { "GPCMD_READ_10", GPCMD_READ_10 }, 00073 { "GPCMD_READ_12", GPCMD_READ_12 }, 00074 #ifdef GPCMD_READ_BUFFER 00075 { "GPCMD_READ_BUFFER", GPCMD_READ_BUFFER }, 00076 #endif 00077 { "GPCMD_READ_BUFFER_CAPACITY", GPCMD_READ_BUFFER_CAPACITY }, 00078 { "GPCMD_READ_CDVD_CAPACITY", GPCMD_READ_CDVD_CAPACITY }, 00079 { "GPCMD_READ_CD", GPCMD_READ_CD }, 00080 { "GPCMD_READ_CD_MSF", GPCMD_READ_CD_MSF }, 00081 { "GPCMD_READ_DISC_INFO", GPCMD_READ_DISC_INFO }, 00082 { "GPCMD_READ_DVD_STRUCTURE", GPCMD_READ_DVD_STRUCTURE }, 00083 { "GPCMD_READ_FORMAT_CAPACITIES", GPCMD_READ_FORMAT_CAPACITIES }, 00084 { "GPCMD_READ_HEADER", GPCMD_READ_HEADER }, 00085 { "GPCMD_READ_TRACK_RZONE_INFO", GPCMD_READ_TRACK_RZONE_INFO }, 00086 { "GPCMD_READ_SUBCHANNEL", GPCMD_READ_SUBCHANNEL }, 00087 { "GPCMD_READ_TOC_PMA_ATIP", GPCMD_READ_TOC_PMA_ATIP }, 00088 { "GPCMD_REPAIR_RZONE_TRACK", GPCMD_REPAIR_RZONE_TRACK }, 00089 { "GPCMD_REPORT_KEY", GPCMD_REPORT_KEY }, 00090 { "GPCMD_REQUEST_SENSE", GPCMD_REQUEST_SENSE }, 00091 { "GPCMD_RESERVE_RZONE_TRACK", GPCMD_RESERVE_RZONE_TRACK }, 00092 { "GPCMD_SEND_CUE_SHEET", GPCMD_SEND_CUE_SHEET }, 00093 { "GPCMD_SCAN", GPCMD_SCAN }, 00094 { "GPCMD_SEEK", GPCMD_SEEK }, 00095 { "GPCMD_SEND_DVD_STRUCTURE", GPCMD_SEND_DVD_STRUCTURE }, 00096 { "GPCMD_SEND_EVENT", GPCMD_SEND_EVENT }, 00097 { "GPCMD_SEND_KEY", GPCMD_SEND_KEY }, 00098 { "GPCMD_SEND_OPC", GPCMD_SEND_OPC }, 00099 { "GPCMD_SET_READ_AHEAD", GPCMD_SET_READ_AHEAD }, 00100 { "GPCMD_SET_STREAMING", GPCMD_SET_STREAMING }, 00101 { "GPCMD_START_STOP_UNIT", GPCMD_START_STOP_UNIT }, 00102 { "GPCMD_STOP_PLAY_SCAN", GPCMD_STOP_PLAY_SCAN }, 00103 { "GPCMD_TEST_UNIT_READY", GPCMD_TEST_UNIT_READY }, 00104 { "GPCMD_VERIFY_10", GPCMD_VERIFY_10 }, 00105 { "GPCMD_WRITE_10", GPCMD_WRITE_10 }, 00106 #ifdef GPCMD_WRITE_12 00107 { "GPCMD_WRITE_12", GPCMD_WRITE_12 }, 00108 #endif 00109 { "GPCMD_WRITE_AND_VERIFY_10", GPCMD_WRITE_AND_VERIFY_10 }, 00110 #ifdef GPCMD_WRITE_BUFFER 00111 { "GPCMD_WRITE_BUFFER", GPCMD_WRITE_BUFFER }, 00112 #endif 00113 { "GPCMD_SET_SPEED", GPCMD_SET_SPEED }, 00114 { "GPCMD_PLAYAUDIO_TI", GPCMD_PLAYAUDIO_TI }, 00115 { "GPCMD_GET_MEDIA_STATUS", GPCMD_GET_MEDIA_STATUS }, 00116 }; 00117 00118 explain_parse_bits_print_single(sb, cmd, table, SIZEOF(table)); 00119 } 00120 00121 00122 void 00123 explain_buffer_cdrom_generic_command(explain_string_buffer_t *sb, 00124 const struct cdrom_generic_command *data) 00125 { 00126 if (explain_is_efault_pointer(data, sizeof(*data))) 00127 { 00128 explain_buffer_pointer(sb, data); 00129 return; 00130 } 00131 00132 explain_string_buffer_puts(sb, "{ cmd = { "); 00133 explain_buffer_gpcmd(sb, data->cmd[0]); 00134 explain_string_buffer_putc(sb, ','); 00135 explain_buffer_hexdump(sb, data->cmd + 1, sizeof(data->cmd) - 1); 00136 explain_string_buffer_puts(sb, "}, buffer = "); 00137 explain_buffer_pointer(sb, data->buffer); 00138 explain_string_buffer_puts(sb, ", buflen = "); 00139 explain_buffer_long(sb, data->buflen); 00140 explain_string_buffer_puts(sb, ", stat = "); 00141 explain_buffer_long(sb, data->stat); 00142 explain_string_buffer_puts(sb, ", sense = "); 00143 explain_buffer_pointer(sb, data->sense); 00144 explain_string_buffer_puts(sb, ", data_direction = "); 00145 explain_buffer_data_direction(sb, data->data_direction); 00146 explain_string_buffer_puts(sb, ", quiet = "); 00147 explain_buffer_long(sb, data->quiet); 00148 explain_string_buffer_puts(sb, ", timeout = "); 00149 explain_buffer_long(sb, data->timeout); 00150 explain_string_buffer_puts(sb, " }"); 00151 } 00152 00153 #else 00154 00155 void 00156 explain_buffer_cdrom_generic_command(explain_string_buffer_t *sb, 00157 const struct cdrom_generic_command *data) 00158 { 00159 explain_buffer_pointer(sb, data); 00160 } 00161 00162 #endif 00163 00164 00165 /* vim: set ts=8 sw=4 et : */